Package com.badlogic.gdx.math
Class GridPoint2
- java.lang.Object
-
- com.badlogic.gdx.math.GridPoint2
-
- All Implemented Interfaces:
java.io.Serializable
public class GridPoint2 extends java.lang.Object implements java.io.Serializable
A point in a 2D grid, with integer x and y coordinates- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GridPoint2()
Constructs a new 2D grid point.GridPoint2(int x, int y)
Constructs a new 2D grid point.GridPoint2(GridPoint2 point)
Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GridPoint2
add(int x, int y)
Adds another 2D grid point to this point.GridPoint2
add(GridPoint2 other)
Adds another 2D grid point to this point.GridPoint2
cpy()
float
dst(int x, int y)
float
dst(GridPoint2 other)
float
dst2(int x, int y)
float
dst2(GridPoint2 other)
boolean
equals(java.lang.Object o)
int
hashCode()
GridPoint2
set(int x, int y)
Sets the coordinates of this 2D grid point.GridPoint2
set(GridPoint2 point)
Sets the coordinates of this 2D grid point to that of another.GridPoint2
sub(int x, int y)
Subtracts another 2D grid point from this point.GridPoint2
sub(GridPoint2 other)
Subtracts another 2D grid point from this point.java.lang.String
toString()
-
-
-
Constructor Detail
-
GridPoint2
public GridPoint2()
Constructs a new 2D grid point.
-
GridPoint2
public GridPoint2(int x, int y)
Constructs a new 2D grid point.- Parameters:
x
- X coordinatey
- Y coordinate
-
GridPoint2
public GridPoint2(GridPoint2 point)
Copy constructor- Parameters:
point
- The 2D grid point to make a copy of.
-
-
Method Detail
-
set
public GridPoint2 set(GridPoint2 point)
Sets the coordinates of this 2D grid point to that of another.- Parameters:
point
- The 2D grid point to copy the coordinates of.- Returns:
- this 2D grid point for chaining.
-
set
public GridPoint2 set(int x, int y)
Sets the coordinates of this 2D grid point.- Parameters:
x
- X coordinatey
- Y coordinate- Returns:
- this 2D grid point for chaining.
-
dst2
public float dst2(GridPoint2 other)
- Parameters:
other
- The other point- Returns:
- the squared distance between this point and the other point.
-
dst2
public float dst2(int x, int y)
- Parameters:
x
- The x-coordinate of the other pointy
- The y-coordinate of the other point- Returns:
- the squared distance between this point and the other point.
-
dst
public float dst(GridPoint2 other)
- Parameters:
other
- The other point- Returns:
- the distance between this point and the other vector.
-
dst
public float dst(int x, int y)
- Parameters:
x
- The x-coordinate of the other pointy
- The y-coordinate of the other point- Returns:
- the distance between this point and the other point.
-
add
public GridPoint2 add(GridPoint2 other)
Adds another 2D grid point to this point.- Parameters:
other
- The other point- Returns:
- this 2d grid point for chaining.
-
add
public GridPoint2 add(int x, int y)
Adds another 2D grid point to this point.- Parameters:
x
- The x-coordinate of the other pointy
- The y-coordinate of the other point- Returns:
- this 2d grid point for chaining.
-
sub
public GridPoint2 sub(GridPoint2 other)
Subtracts another 2D grid point from this point.- Parameters:
other
- The other point- Returns:
- this 2d grid point for chaining.
-
sub
public GridPoint2 sub(int x, int y)
Subtracts another 2D grid point from this point.- Parameters:
x
- The x-coordinate of the other pointy
- The y-coordinate of the other point- Returns:
- this 2d grid point for chaining.
-
cpy
public GridPoint2 cpy()
- Returns:
- a copy of this grid point
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-