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 Details

    • Position

      public Position(double x, double y, double z, double heading)
      Creates an instance of a Position record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
      z - the value for the z record component
      heading - the value for the heading 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

      public static Position of2d(double x, double y)
    • toString

      public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • toStringShort

      public String toStringShort()
    • equals

      public boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • distanceFrom2D

      public double distanceFrom2D(Position other)
    • translateAbsolute

      public Position translateAbsolute(double deltaX, double deltaY)
    • translateRelative

      public Position translateRelative(double right, double forward)
      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

      public Position normalizedTo(Position basis)
    • facing

      public Position facing(double angle)
      Returns this position, but with a new heading.
      Parameters:
      angle - The new heading
      Returns:
      The new position.
    • facing

      public Position facing(Position faceTowards)
      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 the x record component.
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • z

      public double z()
      Returns the value of the z record component.
      Returns:
      the value of the z record component
    • heading

      public double heading()
      Returns the value of the heading record component.
      Returns:
      the value of the heading record component