Class Point2i

Object
org.anchoranalysis.spatial.point.Point2i
All Implemented Interfaces:
Serializable

public final class Point2i
extends Object
implements Serializable
A two-dimensional point of int values.

We consider a point to be a tuple representing a single physical point in space.

Author:
Owen Feehan
See Also:
Serialized Form
  • Constructor Details

    • Point2i

      public Point2i​(Point2i point)
      Creates with the same values as an existing Point2i.
      Parameters:
      point - to copy values from.
    • Point2i

      public Point2i​(int x, int y)
    • Point2i

      public Point2i()
  • Method Details

    • x

      public int x()
      X-axis component of point.
      Returns:
      the component value.
    • y

      public int y()
      Y-axis component of point.
      Returns:
      the component value.
    • incrementX

      public void incrementX()
      Increments the X component's value by one.
    • incrementY

      public void incrementY()
      Increments the Y component's value by one.
    • incrementX

      public void incrementX​(int shift)
      Increments the X component's value by a shift.
      Parameters:
      shift - how much to increment by.
    • incrementY

      public void incrementY​(int shift)
      Increments the Y component's value by a shift.
      Parameters:
      shift - how much to increment by.
    • add

      public void add​(Point2i point)
      Adds values from a Point2i across each corresponding dimension.
      Parameters:
      point - the point whose values are added.
    • toArray

      public double[] toArray()
      Converts the point to an array.
      Returns:
      a newly created array with two elements, respectively for x and y components.
    • immutableAdd

      public static Point2i immutableAdd​(Point2i point1, Point2i point2)
      Adds two points immutably.
      Parameters:
      point1 - the first point to add.
      point2 - the second point to add.
      Returns:
      a newly created point, where each dimension is the sum of the corresponding dimensions in the points.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • setX

      public void setX​(int x)
      X-axis component of point.
    • setY

      public void setY​(int y)
      Y-axis component of point.