Record Class Rotation

java.lang.Object
java.lang.Record
com.zenith.feature.player.Rotation

public record Rotation(float yaw, float pitch) extends Record
  • Constructor Details

    • Rotation

      public Rotation(float yaw, float pitch)
      Creates an instance of a Rotation record class.
      Parameters:
      yaw - the value for the yaw record component
      pitch - the value for the pitch record component
  • Method Details

    • add

      public Rotation add(Rotation other)
      Adds the yaw/pitch of the specified rotations to this rotation's yaw/pitch, and returns the result.
      Parameters:
      other - Another rotation
      Returns:
      The result from adding the other rotation to this rotation
    • subtract

      public Rotation subtract(Rotation other)
      Subtracts the yaw/pitch of the specified rotations from this rotation's yaw/pitch, and returns the result.
      Parameters:
      other - Another rotation
      Returns:
      The result from subtracting the other rotation from this rotation
    • clamp

      public Rotation clamp()
      Returns:
      A copy of this rotation with the pitch clamped
    • normalize

      public Rotation normalize()
      Returns:
      A copy of this rotation with the yaw normalized
    • normalizeAndClamp

      public Rotation normalizeAndClamp()
      Returns:
      A copy of this rotation with the pitch clamped and the yaw normalized
    • withPitch

      public Rotation withPitch(float pitch)
    • isReallyCloseTo

      public boolean isReallyCloseTo(Rotation other)
      Is really close to
      Parameters:
      other - another rotation
      Returns:
      are they really close
    • isCloseTo

      public boolean isCloseTo(Rotation other, float threshold)
    • yawIsReallyClose

      public boolean yawIsReallyClose(Rotation other)
    • yawIsClose

      public boolean yawIsClose(Rotation other, float threshold)
    • clampPitch

      public static float clampPitch(float pitch)
      Clamps the specified pitch value between -90 and 90.
      Parameters:
      pitch - The input pitch
      Returns:
      The clamped pitch
    • normalizeYaw

      public static float normalizeYaw(float yaw)
      Normalizes the specified yaw value between -180 and 180.
      Parameters:
      yaw - The input yaw
      Returns:
      The normalized yaw
    • toString

      public final 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
    • hashCode

      public final 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
    • equals

      public final 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 the compare method from their corresponding wrapper classes.
      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.
    • yaw

      public float yaw()
      Returns the value of the yaw record component.
      Returns:
      the value of the yaw record component
    • pitch

      public float pitch()
      Returns the value of the pitch record component.
      Returns:
      the value of the pitch record component