Package arc.math.geom
Class Point2
java.lang.Object
arc.math.geom.Point2
A point in a 2D grid, with integer x and y coordinates
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(int x, int y) Adds another 2D grid point to this point.Adds another 2D grid point to this point.cpy()
float
dst
(int x, int y) float
float
dst2
(int x, int y) float
boolean
equals
(int x, int y) static boolean
equals
(int x, int y, int ox, int oy) boolean
int
hashCode()
int
pack()
static int
pack
(int x, int y) rotate
(int steps) Rotates this point in 90-degree increments several times.set
(int x, int y) Sets the coordinates of this 2D grid point.Sets the coordinates of this 2D grid point to that of another.sub
(int x, int y) Subtracts another 2D grid point from this point.Subtracts another 2D grid point from this point.toString()
static Point2
unpack
(int pos) static short
x
(int pos) static short
y
(int pos)
-
Field Details
-
x
public int x -
y
public int y
-
-
Constructor Details
-
Point2
public Point2()Constructs a new 2D grid point. -
Point2
public Point2(int x, int y) Constructs a new 2D grid point.- Parameters:
x
- X coordinatey
- Y coordinate
-
Point2
Copy constructor- Parameters:
point
- The 2D grid point to make a copy of.
-
-
Method Details
-
unpack
- Returns:
- a point unpacked from an integer.
-
pack
public static int pack(int x, int y) - Returns:
- this point packed into a single int by casting its components to shorts.
-
x
public static short x(int pos) - Returns:
- the x component of a packed position.
-
y
public static short y(int pos) - Returns:
- the y component of a packed position.
-
pack
public int pack()- Returns:
- this point packed into a single int by casting its components to shorts.
-
set
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
Sets the coordinates of this 2D grid point.- Parameters:
x
- X coordinatey
- Y coordinate- Returns:
- this 2D grid point for chaining.
-
dst2
- 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
- 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
Adds another 2D grid point to this point.- Parameters:
other
- The other point- Returns:
- this 2d grid point for chaining.
-
add
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
Subtracts another 2D grid point from this point.- Parameters:
other
- The other point- Returns:
- this 2d grid point for chaining.
-
sub
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
- Returns:
- a copy of this grid point
-
rotate
Rotates this point in 90-degree increments several times. -
equals
public boolean equals(int x, int y) -
equals
public static boolean equals(int x, int y, int ox, int oy) -
equals
-
hashCode
public int hashCode() -
toString
-