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
ConstructorsConstructorDescriptionPosition(double x, double y, double z, double heading) Creates an instance of aPositionrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubledistanceFrom2D(Position other) booleanIndicates 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.doubledoublegetX()doublegetY()doublegetZ()inthashCode()Returns a hash code value for this object.doubleheading()Returns the value of theheadingrecord component.static Positionintersection(Position a, Position b) Given two positions, compute the intersection of the positions if you were to draw a line extending forward and back from the point.normalizedTo(Position basis) doublestatic Positionof2d(double x, double y) static PositionGiven two positions, compute the intersection of the positions if you were to draw a line perpendicular to each position's facing.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.doublex()Returns the value of thexrecord component.doubley()Returns the value of theyrecord component.doublez()Returns the value of thezrecord component.
-
Constructor Details
-
Position
public Position(double x, double y, double z, double heading) Creates an instance of aPositionrecord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord componentz- the value for thezrecord componentheading- the value for theheadingrecord 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.
-
intersection
Given two positions, compute the intersection of the positions if you were to draw a line extending forward and back from the point.- Parameters:
a- The first positionb- The second position- Returns:
- The intersection, using the z coordinate of the first position.
-
perpendicularIntersection
Given two positions, compute the intersection of the positions if you were to draw a line perpendicular to each position's facing. Ignores Z-axis entirely for the purposes of intersection.- Parameters:
a- The first positionb- The second position- Returns:
- The intersection, using the z coordinate of the first position.
-
x
public double x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public double y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-
z
public double z()Returns the value of thezrecord component.- Returns:
- the value of the
zrecord component
-
heading
public double heading()Returns the value of theheadingrecord component.- Returns:
- the value of the
headingrecord component
-