Class GridPoint
java.lang.Object
Jcg.geometry.GridPoint
A class for representing a 2D point (a cell) on an integer grid.
- Author:
- Luca Castelli Aleardi (jan 2021)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanCheck whether two points have equal coordinatesdoubleReturn the Euclidean distance between the current point 'this' and a point 'p'intgetCartesian(int dim) Return the d-th coordinate of the pointintgetX()Return the x-coordinateintgetY()Return the y-coordinateinthashCode()intReturn the Manhattan distance between the current point 'this' and a point 'p'voidsetCartesian(int dim, int x) Set the d-th coordinate of the pointvoidvoidsetX(int x) Set the x-coordinatevoidsetY(int y) Set the y-coordinateintReturn the square of the Euclidean distance between the current point 'this' and a point 'p'toString()voidtranslateOf(int dx, int dy) Translate the current point of the vector (dx, dy)
-
Field Details
-
index
public int indexan integer useful for indexing this point: for instance, 'index' can be the number of a vertex -
x
private int xinteger coordinates of the point on the grid -
y
private int yinteger coordinates of the point on the grid
-
-
Constructor Details
-
GridPoint
public GridPoint()Initialize an empty point -
GridPoint
public GridPoint(int x, int y) Initialize an integer point having coordinates (x, y) -
GridPoint
Make a copy of a point q
-
-
Method Details
-
getX
public int getX()Return the x-coordinate -
getY
public int getY()Return the y-coordinate -
setX
public void setX(int x) Set the x-coordinate -
setY
public void setY(int y) Set the y-coordinate -
translateOf
public void translateOf(int dx, int dy) Translate the current point of the vector (dx, dy) -
equals
-
hashCode
-
euclideanDistance
Return the Euclidean distance between the current point 'this' and a point 'p' -
manhattanDistance
Return the Manhattan distance between the current point 'this' and a point 'p' -
squareEuclideanDistance
Return the square of the Euclidean distance between the current point 'this' and a point 'p' -
toString
-
dimension
public int dimension() -
getCartesian
public int getCartesian(int dim) Return the d-th coordinate of the point -
setCartesian
public void setCartesian(int dim, int x) Set the d-th coordinate of the point -
setOrigin
public void setOrigin()
-