Package org.anchoranalysis.spatial.point
Class Point2i
Object
Point2i
- All Implemented Interfaces:
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds values from aPoint2i
across each corresponding dimension.boolean
int
hashCode()
static Point2i
immutableAdd
(Point2i point1, Point2i point2) Adds two points immutably.void
Increments the X component's value by one.void
incrementX
(int shift) Increments the X component's value by a shift.void
Increments the Y component's value by one.void
incrementY
(int shift) Increments the Y component's value by a shift.void
setX
(int x) X-axis component of point.void
setY
(int y) Y-axis component of point.double[]
toArray()
Converts the point to an array.toString()
int
x()
X-axis component of point.int
y()
Y-axis component of point.
-
Constructor Details
-
Point2i
Creates with the same values as an existingPoint2i
.- Parameters:
point
- to copy values from.
-
Point2i
public Point2i(int x, int y) Creates a newPoint2i
instance.- Parameters:
x
- X-axis component of point.y
- Y-axis component of point.
-
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
Adds values from aPoint2i
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
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
-
equals
-
hashCode
public int hashCode() -
setX
public void setX(int x) X-axis component of point. -
setY
public void setY(int y) Y-axis component of point.
-