Package xyz.calcugames.levelz.coord
Class Coordinate2D
java.lang.Object
xyz.calcugames.levelz.coord.Coordinate2D
- All Implemented Interfaces:
Comparable<Coordinate>
,Coordinate
Represents a 2-Dimensional Coordinate.
-
Constructor Summary
ConstructorDescriptionCoordinate2D
(double[] xy) Constructs a 2D Coordinate.Coordinate2D
(double x, double y) Constructs a 2D Coordinate.Coordinate2D
(float[] xy) Constructs a 2D Coordinate.Coordinate2D
(float x, float y) Constructs a 2D Coordinate.Coordinate2D
(int[] xy) Constructs a 2D Coordinate.Coordinate2D
(int x, int y) Constructs a 2D Coordinate. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static @NotNull Coordinate2D
fromString
(String point) Parses a 2D Coordinate from a string.Gets the dimension of the Coordinate.double
getDistance
(@NotNull Coordinate coordinate) Gets the distance between two Coordinates.double
Gets the magnitude of the Coordinate.double
getX()
Gets the X Value of the Coordinate.double
getY()
Gets the Y Value of the Coordinate.int
hashCode()
void
setX
(double x) Sets the X Value of the Coordinate.void
setX
(int x) Gets the Y Value of the Coordinate.void
setY
(double y) Sets the Y Value of the Coordinate.void
setY
(int y) Sets the Y Value of the Coordinate.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface xyz.calcugames.levelz.coord.Coordinate
compareTo
-
Constructor Details
-
Coordinate2D
public Coordinate2D(int x, int y) Constructs a 2D Coordinate.- Parameters:
x
- X Valuey
- Y Value
-
Coordinate2D
public Coordinate2D(int[] xy) Constructs a 2D Coordinate.- Parameters:
xy
- Array of X and Y Values
-
Coordinate2D
public Coordinate2D(float x, float y) Constructs a 2D Coordinate.- Parameters:
x
- X Valuey
- Y Value
-
Coordinate2D
public Coordinate2D(float[] xy) Constructs a 2D Coordinate.- Parameters:
xy
- Array of X and Y Values
-
Coordinate2D
public Coordinate2D(double x, double y) Constructs a 2D Coordinate.- Parameters:
x
- X Valuey
- Y Value
-
Coordinate2D
public Coordinate2D(double[] xy) Constructs a 2D Coordinate.- Parameters:
xy
- Array of X and Y Values
-
-
Method Details
-
getX
public double getX()Gets the X Value of the Coordinate.- Returns:
- X Value
-
setX
public void setX(double x) Sets the X Value of the Coordinate.- Parameters:
x
- X Value
-
setX
public void setX(int x) Gets the Y Value of the Coordinate.- Parameters:
x
- X Value
-
getY
public double getY()Gets the Y Value of the Coordinate.- Returns:
- Y Value
-
setY
public void setY(int y) Sets the Y Value of the Coordinate.- Parameters:
y
- Y Value
-
setY
public void setY(double y) Sets the Y Value of the Coordinate.- Parameters:
y
- Y Value
-
getDistance
Description copied from interface:Coordinate
Gets the distance between two Coordinates.- Specified by:
getDistance
in interfaceCoordinate
- Parameters:
coordinate
- Other Coordinate- Returns:
- Distance between Coordinates
-
getMagnitude
public double getMagnitude()Description copied from interface:Coordinate
Gets the magnitude of the Coordinate.- Specified by:
getMagnitude
in interfaceCoordinate
- Returns:
- Coordinate Magnitude
-
getDimension
Description copied from interface:Coordinate
Gets the dimension of the Coordinate.- Specified by:
getDimension
in interfaceCoordinate
- Returns:
- Coordinate Dimension
-
equals
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCoordinate
- Overrides:
hashCode
in classObject
-
toString
- Specified by:
toString
in interfaceCoordinate
- Overrides:
toString
in classObject
-
fromString
Parses a 2D Coordinate from a string.- Parameters:
point
- String- Returns:
- 2D Coordinate
-