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
ConstructorsConstructorDescriptionCoordinate2D(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 TypeMethodDescriptionbooleanstatic @NotNull Coordinate2DfromString(String point) Parses a 2D Coordinate from a string.Gets the dimension of the Coordinate.doublegetDistance(@NotNull Coordinate coordinate) Gets the distance between two Coordinates.doubleGets the magnitude of the Coordinate.doublegetX()Gets the X Value of the Coordinate.doublegetY()Gets the Y Value of the Coordinate.inthashCode()voidsetX(double x) Sets the X Value of the Coordinate.voidsetX(int x) Gets the Y Value of the Coordinate.voidsetY(double y) Sets the Y Value of the Coordinate.voidsetY(int y) Sets the Y Value of the Coordinate.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:CoordinateGets the distance between two Coordinates.- Specified by:
getDistancein interfaceCoordinate- Parameters:
coordinate- Other Coordinate- Returns:
- Distance between Coordinates
-
getMagnitude
public double getMagnitude()Description copied from interface:CoordinateGets the magnitude of the Coordinate.- Specified by:
getMagnitudein interfaceCoordinate- Returns:
- Coordinate Magnitude
-
getDimension
Description copied from interface:CoordinateGets the dimension of the Coordinate.- Specified by:
getDimensionin interfaceCoordinate- Returns:
- Coordinate Dimension
-
equals
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCoordinate- Overrides:
hashCodein classObject
-
toString
- Specified by:
toStringin interfaceCoordinate- Overrides:
toStringin classObject
-
fromString
Parses a 2D Coordinate from a string.- Parameters:
point- String- Returns:
- 2D Coordinate
-