-
public class Coordinate
-
-
Constructor Summary
Constructors Constructor Description Coordinate(Number xCoord, Number yCoord)
Creates a Coordinate with given xCoord and yCoord.
-
Method Summary
Modifier and Type Method Description final Double
getXCoord()
X coordinate. final Double
getYCoord()
Y coordinate. final Coordinate
plus(Coordinate other)
Returns a new coordinate object containing added xCoord and yCoord. final Coordinate
minus(Coordinate other)
Returns a new coordinate object containing subtracted xCoord and yCoord. final Coordinate
times(Number factor)
Returns a new coordinate object containing multiplied Coordinate with factor. final Coordinate
div(Number denominator)
Returns a new coordinate object containing divided Coordinate by denominator. final Coordinate
rotated(Number angle, Coordinate center)
Rotates Coordinate by angle degrees around center point. final Coordinate
rotated(Double angle)
Rotates coordinate by angle degrees around point (0,0). String
toString()
Prints xCoord and yCoord as String. Boolean
equals(Object other)
Compares coordinate to another Object. Integer
hashCode()
HashCode for this object. -
-
Constructor Detail
-
Coordinate
Coordinate(Number xCoord, Number yCoord)
Creates a Coordinate with given xCoord and yCoord.- Parameters:
xCoord
- The x coordinate.yCoord
- The y coordinate.
-
-
Method Detail
-
plus
final Coordinate plus(Coordinate other)
- Parameters:
other
- Coordinate to add.
-
minus
final Coordinate minus(Coordinate other)
- Parameters:
other
- Coordinate to subtract.
-
times
final Coordinate times(Number factor)
Returns a new coordinate object containing multiplied Coordinate with factor.
- Parameters:
factor
- factor to multiply with.
-
div
final Coordinate div(Number denominator)
Returns a new coordinate object containing divided Coordinate by denominator.
- Parameters:
denominator
- denominator to divide by.
-
rotated
final Coordinate rotated(Number angle, Coordinate center)
Rotates Coordinate by angle degrees around center point.
With
Angle t,
Center point Z
Coordinate P
cos(phi) -sin(phi) * Px - Zx + Zx = cos(phi)*(Px-Zx) - sin(phi)*(Py-Zy) + Zx
Py - Zy sin(phi)*(Px-Zx) + cos(phi)*(Py-Zy) + Zy
-
rotated
final Coordinate rotated(Double angle)
Rotates coordinate by angle degrees around point (0,0).
With
Angle t,
Center point Z
Coordinate P
cos(phi) -sin(phi) * Px - Zx + Zx = cos(phi)*(Px-Zx) - sin(phi)*(Py-Zy) + Zx
Py - Zy sin(phi)*(Px-Zx) + cos(phi)*(Py-Zy) + Zy
-
-
-
-