Package org.anchoranalysis.spatial.point
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 Summary
-
Method Summary
Modifier and Type Method Description voidadd(Point2i point)Adds values from aPoint2iacross each corresponding dimension.booleanequals(Object o)inthashCode()static Point2iimmutableAdd(Point2i point1, Point2i point2)Adds two points immutably.voidincrementX()Increments the X component's value by one.voidincrementX(int shift)Increments the X component's value by a shift.voidincrementY()Increments the Y component's value by one.voidincrementY(int shift)Increments the Y component's value by a shift.voidsetX(int x)X-axis component of point.voidsetY(int y)Y-axis component of point.double[]toArray()Converts the point to an array.StringtoString()intx()X-axis component of point.inty()Y-axis component of point.
-
Constructor Details
-
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 aPoint2iacross 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.
-