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 TypeMethodDescriptionvoidAdds values from aPoint2iacross each corresponding dimension.booleaninthashCode()static Point2iimmutableAdd(Point2i point1, Point2i point2) Adds two points immutably.voidIncrements the X component's value by one.voidincrementX(int shift) Increments the X component's value by a shift.voidIncrements 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.toString()intx()X-axis component of point.inty()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 newPoint2iinstance.- 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 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.
-