Package gg.xp.xivsupport.models
Record Class Position
java.lang.Object
java.lang.Record
gg.xp.xivsupport.models.Position
- All Implemented Interfaces:
Serializable
public record Position(double x, double y, double z, double heading)
extends Record
implements Serializable
- See Also:
-
Constructor Summary
ConstructorDescriptionPosition
(double x, double y, double z, double heading) Creates an instance of aPosition
record class. -
Method Summary
Modifier and TypeMethodDescriptiondouble
distanceFrom2D
(Position other) boolean
Indicates whether some other object is "equal to" this one.facing
(double angle) Returns this position, but with a new heading.Returns this position, but with the heading modified to face towards the given position.double
double
getX()
double
getY()
double
getZ()
int
hashCode()
Returns a hash code value for this object.double
heading()
Returns the value of theheading
record component.normalizedTo
(Position basis) double
static Position
of2d
(double x, double y) toString()
Returns a string representation of this record class.translateAbsolute
(double deltaX, double deltaY) translateRelative
(double right, double forward) Performs a translation of this position, using its facing angle.double
x()
Returns the value of thex
record component.double
y()
Returns the value of they
record component.double
z()
Returns the value of thez
record component.
-
Constructor Details
-
Position
public Position(double x, double y, double z, double heading) Creates an instance of aPosition
record class.- Parameters:
x
- the value for thex
record componenty
- the value for they
record componentz
- the value for thez
record componentheading
- the value for theheading
record component
-
-
Method Details
-
getX
public double getX()- Returns:
- The X coordinate (-x is West, +x is East).
-
getY
public double getY()- Returns:
- The Y coordinate (-y is North, +y is South).
-
getZ
public double getZ()- Returns:
- The Z coordinate
-
getHeading
public double getHeading()- Returns:
- The heading in radians (+pi and -pi are north, 0 is south, -pi/2 is west, +pi/2 is east)
-
of2d
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
toStringShort
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
distanceFrom2D
-
translateAbsolute
-
translateRelative
Performs a translation of this position, using its facing angle.- Parameters:
right
- How far right (based on its facing angle) to move the position.forward
- How far forward (based on its facing angle) to move the position.- Returns:
- a new Position object that has been translated in the X-Y plane, with the same Z and heading.
-
northUpClockwiseHeading
public double northUpClockwiseHeading()- Returns:
- The heading, but instead oriented so that zero is north, and clockwise rotation is positive heading.
-
normalizedTo
-
facing
Returns this position, but with a new heading.- Parameters:
angle
- The new heading- Returns:
- The new position.
-
facing
Returns this position, but with the heading modified to face towards the given position.- Parameters:
faceTowards
- The position to face.- Returns:
- A new position with the same x/y/z as 'this', but a new heading. If the given position's x and y components are the same as those of this position, return this position unmodified.
-
x
public double x()Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
public double y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-
z
public double z()Returns the value of thez
record component.- Returns:
- the value of the
z
record component
-
heading
public double heading()Returns the value of theheading
record component.- Returns:
- the value of the
heading
record component
-