Class Rotation3f

java.lang.Object
com.hypixel.hytale.math.vector.Rotation3f
All Implemented Interfaces:
Rotation3fc

public class Rotation3f extends Object implements Rotation3fc
A 3-dimensional Euler rotation with single-precision floating point components.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BuilderCodec<Rotation3f>
    The codec used to parse a Rotation3f instance as rotation.
    static final Rotation3fc
     
    static final Rotation3fc
     
    static final BuilderCodec<Rotation3f>
    The codec used to parse a Rotation3f instance as rotation with default values of Float.NaN.
    float
    The X component of the rotation.
    float
    The Y component of the rotation.
    float
    The Z component of the rotation.
    static final Rotation3fc
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Empty Constructor for a Rotation3f instance.
    Rotation3f(float pitch, float yaw, float roll)
    Constructor for a Rotation3f instance.
    Default Copy Constructor for a Rotation3f instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(float x, float y, float z)
    Called to add values to this rotation.
    Called to add another rotation to this one.
    void
    addPitch(float pitch)
    Called to add pitch value to this rotation.
    void
    addRoll(float roll)
    Called to add roll value to this rotation.
    void
    addRotationOnAxis(Axis axis, int degrees)
    Called to add rotation to this rotation based on the axis.
    void
    addYaw(float yaw)
    Called to add yaw value to this rotation.
     
    float
    distanceSquaredTo(float x, float y, float z)
    Called to compute the squared distance from this rotation to the given components.
    boolean
     
    void
    Called to flip the rotation on the given axis.
    org.joml.Quaterniond
    getQuaternion(org.joml.Quaterniond dest)
    Get the rotation represented by this rotation and stores it into the given Quaterniond.
    int
     
    boolean
     
    static Rotation3f
    lerp(Rotation3f a, Rotation3f b, float t)
    Called to linearly interpolate between two rotations.
    static Rotation3f
    Called to linearly interpolate between two angles.
    static Rotation3f
    lerpAngle(Rotation3fc a, Rotation3fc b, float t, Rotation3f target)
    Called to linearly interpolate between two angles and store it in a target rotation.
    static Rotation3f
    Called to linearly interpolate between two rotations without clamping.
    static Rotation3f
    lookAt(double dx, double dy, double dz)
    Called to compute the look at rotation for a relative direction.
    static Rotation3f
    lookAt(double dx, double dy, double dz, Rotation3f result)
    Called to compute the look at rotation for a relative direction and store it in a result rotation.
    static Rotation3f
    lookAt(org.joml.Vector3dc relative)
    Called to compute the look at rotation for a relative rotation.
    static Rotation3f
    lookAt(org.joml.Vector3dc relative, Rotation3f result)
    Called to compute the look at rotation for a relative rotation and store it in a result rotation.
    static Rotation3f
    lookAt(org.joml.Vector3dc eye, org.joml.Vector3dc target)
    Called to compute the look at rotation from an eye position to a target position.
    static Rotation3f
    lookAt(org.joml.Vector3dc eye, org.joml.Vector3dc target, Rotation3f result)
    Called to compute the look at rotation from an eye position to a target position and store it in a result rotation.
    mul(float s)
    Called to scale this rotation.
    Called to scale this rotation by another rotation.
    mul(org.joml.Quaterniondc q)
     
    mul(org.joml.Quaterniondc q, Rotation3f dest)
    Rotate these Euler angles by q and store the result in dest.
    Called to negate this rotation.
    float
     
    premul(org.joml.Quaterniondc q)
     
    premul(org.joml.Quaterniondc q, Rotation3f dest)
    Pre-rotate these Euler angles by q and store the result in dest.
    float
     
    void
    Replaces any non-finite component (NaN or infinity) with 0, in place.
    set(float[] v)
    Called to assign the values from an array to this rotation.
    set(float x, float y, float z)
    Called to assign the values to this rotation.
    Called to assign the values of another rotation to this one.
    void
    setPitch(float pitch)
    Called to set the pitch component of the rotation.
    void
    setRoll(float roll)
    Called to set the roll component of the rotation.
    void
    setX(float x)
    Called to set the X component of the rotation.
    void
    setY(float y)
    Called to set the Y component of the rotation.
    void
    setYaw(float yaw)
    Called to set the yaw component of the rotation.
    void
    setZ(float z)
    Called to set the Z component of the rotation.
    sub(float x, float y, float z)
    Called to subtract values from this rotation.
    Called to subtract another rotation from this one.
    sub(org.joml.Vector3i v)
    Called to subtract an integer rotation from this one.
     
    org.joml.Vector3d
    transform(org.joml.Vector3d vec)
    Transform the given vector by this rotation.
    org.joml.Vector3d
    transform(org.joml.Vector3dc vec, org.joml.Vector3d dest)
    Transform the given vector by this rotation and store the result in dest.
    float
    x()
     
    float
    y()
     
    float
    yaw()
     
    float
    z()
     

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CODEC

      @Nonnull public static final BuilderCodec<Rotation3f> CODEC
      The codec used to parse a Rotation3f instance as rotation.
    • PARTIAL_TELEPORT_CODEC

      @Nonnull public static final BuilderCodec<Rotation3f> PARTIAL_TELEPORT_CODEC
      The codec used to parse a Rotation3f instance as rotation with default values of Float.NaN. This allows player teleports to have axis values of Float.NaN and be ignored by the client - enabling relative teleports. CODEC should always be used when default values of zero are supported.
    • ZERO

      public static final Rotation3fc ZERO
    • IDENTITY

      public static final Rotation3fc IDENTITY
    • NaN

      public static final Rotation3fc NaN
    • x

      public float x
      The X component of the rotation.
    • y

      public float y
      The Y component of the rotation.
    • z

      public float z
      The Z component of the rotation.
  • Constructor Details

    • Rotation3f

      public Rotation3f()
      Empty Constructor for a Rotation3f instance.
    • Rotation3f

      public Rotation3f(@Nonnull Rotation3fc v)
      Default Copy Constructor for a Rotation3f instance.
      Parameters:
      v - The rotation to copy.
    • Rotation3f

      public Rotation3f(float pitch, float yaw, float roll)
      Constructor for a Rotation3f instance.
      Parameters:
      pitch - The X component of the rotation.
      yaw - The Y component of the rotation.
      roll - The Z component of the rotation.
  • Method Details

    • x

      public float x()
      Specified by:
      x in interface Rotation3fc
      Returns:
      the X, or pitch component of the rotation.
    • pitch

      public float pitch()
      Specified by:
      pitch in interface Rotation3fc
      Returns:
      the pitch component of the rotation.
    • setX

      public void setX(float x)
      Called to set the X component of the rotation.
      Parameters:
      x - The new X component.
    • setPitch

      public void setPitch(float pitch)
      Called to set the pitch component of the rotation.
      Parameters:
      pitch - The new pitch component.
    • y

      public float y()
      Specified by:
      y in interface Rotation3fc
      Returns:
      the Y, or yaw component of the rotation.
    • yaw

      public float yaw()
      Specified by:
      yaw in interface Rotation3fc
      Returns:
      the yaw component of the rotation.
    • setY

      public void setY(float y)
      Called to set the Y component of the rotation.
      Parameters:
      y - The new Y component.
    • setYaw

      public void setYaw(float yaw)
      Called to set the yaw component of the rotation.
      Parameters:
      yaw - The new yaw component.
    • z

      public float z()
      Specified by:
      z in interface Rotation3fc
      Returns:
      the Z, or roll component of the rotation.
    • roll

      public float roll()
      Specified by:
      roll in interface Rotation3fc
      Returns:
      the roll component of the rotation.
    • setZ

      public void setZ(float z)
      Called to set the Z component of the rotation.
      Parameters:
      z - The new Z component.
    • setRoll

      public void setRoll(float roll)
      Called to set the roll component of the rotation.
      Parameters:
      roll - The new roll component.
    • set

      @Nonnull public Rotation3f set(@Nonnull Rotation3fc v)
      Called to assign the values of another rotation to this one.
      Parameters:
      v - The rotation to copy.
      Returns:
      this rotation.
    • set

      @Nonnull public Rotation3f set(@Nonnull float[] v)
      Called to assign the values from an array to this rotation.
      Parameters:
      v - The array to copy from.
      Returns:
      this rotation.
    • set

      @Nonnull public Rotation3f set(float x, float y, float z)
      Called to assign the values to this rotation.
      Parameters:
      x - The X component to assign.
      y - The Y component to assign.
      z - The Z component to assign.
      Returns:
      this rotation.
    • add

      @Nonnull public Rotation3f add(@Nonnull Rotation3f v)
      Called to add another rotation to this one.
      Parameters:
      v - The rotation to add.
      Returns:
      this rotation.
    • add

      @Nonnull public Rotation3f add(float x, float y, float z)
      Called to add values to this rotation.
      Parameters:
      x - The X component to add.
      y - The Y component to add.
      z - The Z component to add.
      Returns:
      this rotation.
    • addPitch

      public void addPitch(float pitch)
      Called to add pitch value to this rotation.
      Parameters:
      pitch - The pitch value to add.
    • addYaw

      public void addYaw(float yaw)
      Called to add yaw value to this rotation.
      Parameters:
      yaw - The yaw value to add.
    • addRoll

      public void addRoll(float roll)
      Called to add roll value to this rotation.
      Parameters:
      roll - The roll value to add.
    • sub

      @Nonnull public Rotation3f sub(@Nonnull Rotation3f v)
      Called to subtract another rotation from this one.
      Parameters:
      v - The rotation to subtract.
      Returns:
      this rotation.
    • sub

      @Nonnull public Rotation3f sub(@Nonnull org.joml.Vector3i v)
      Called to subtract an integer rotation from this one.
      Parameters:
      v - The rotation to subtract.
      Returns:
      this rotation.
    • sub

      @Nonnull public Rotation3f sub(float x, float y, float z)
      Called to subtract values from this rotation.
      Parameters:
      x - The X component to subtract.
      y - The Y component to subtract.
      z - The Z component to subtract.
      Returns:
      this rotation.
    • addRotationOnAxis

      public void addRotationOnAxis(@Nonnull Axis axis, int degrees)
      Called to add rotation to this rotation based on the axis.
      Parameters:
      axis - The axis.
      degrees - The angle in degrees.
    • flipRotationOnAxis

      public void flipRotationOnAxis(@Nonnull Axis axis)
      Called to flip the rotation on the given axis.
      Parameters:
      axis - The axis.
    • negate

      @Nonnull public Rotation3f negate()
      Called to negate this rotation.
      Returns:
      this rotation.
    • mul

      @Nonnull public Rotation3f mul(float s)
      Called to scale this rotation.
      Parameters:
      s - The scale factor to apply.
      Returns:
      this rotation.
    • mul

      @Nonnull public Rotation3f mul(@Nonnull Rotation3f p)
      Called to scale this rotation by another rotation.
      Parameters:
      p - The rotation to scale by.
      Returns:
      this rotation.
    • distanceSquaredTo

      public float distanceSquaredTo(float x, float y, float z)
      Called to compute the squared distance from this rotation to the given components.
      Parameters:
      x - The X component of the other component.
      y - The Y component of the other component.
      z - The Z component of the other component.
      Returns:
      the squared distance.
    • isFinite

      public boolean isFinite()
      Returns:
      true if all components are finite, false otherwise.
    • sanitizeNonFinite

      public void sanitizeNonFinite()
      Replaces any non-finite component (NaN or infinity) with 0, in place.
    • getQuaternion

      public org.joml.Quaterniond getQuaternion(org.joml.Quaterniond dest)
      Description copied from interface: Rotation3fc
      Get the rotation represented by this rotation and stores it into the given Quaterniond.

      Specified by:
      getQuaternion in interface Rotation3fc
      Parameters:
      dest - the destination Quaterniond
      Returns:
      the passed in destination
    • premul

      public Rotation3f premul(org.joml.Quaterniondc q, Rotation3f dest)
      Description copied from interface: Rotation3fc
      Pre-rotate these Euler angles by q and store the result in dest.

      If T is this and Q is the given quaternion, then the resulting quaternion R is:

      R = Q * T

      Specified by:
      premul in interface Rotation3fc
      Parameters:
      q - the quaternion to pre-multiply this by
      dest - will hold the result
      Returns:
      dest
    • mul

      public Rotation3f mul(org.joml.Quaterniondc q, Rotation3f dest)
      Description copied from interface: Rotation3fc
      Rotate these Euler angles by q and store the result in dest.

      If T is this and Q is the given quaternion, then the resulting quaternion R is:

      R = T * Q

      Specified by:
      mul in interface Rotation3fc
      Parameters:
      q - the quaternion to multiply this by
      dest - will hold the result
      Returns:
      dest
    • premul

      public Rotation3f premul(org.joml.Quaterniondc q)
    • mul

      public Rotation3f mul(org.joml.Quaterniondc q)
    • transform

      public org.joml.Vector3d transform(org.joml.Vector3dc vec, org.joml.Vector3d dest)
      Description copied from interface: Rotation3fc
      Transform the given vector by this rotation and store the result in dest.

      This will apply the rotation described by this to the given vector.

      Specified by:
      transform in interface Rotation3fc
      Parameters:
      vec - the vector to transform
      dest - will hold the result
      Returns:
      dest
    • transform

      public org.joml.Vector3d transform(org.joml.Vector3d vec)
      Description copied from interface: Rotation3fc
      Transform the given vector by this rotation.

      This will apply the rotation described by this to the given vector.

      Specified by:
      transform in interface Rotation3fc
      Parameters:
      vec - the vector to transform
      Returns:
      vec
    • clone

      @Nonnull public Rotation3f clone()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • lerp

      @Nonnull public static Rotation3f lerp(@Nonnull Rotation3f a, @Nonnull Rotation3f b, float t)
      Called to linearly interpolate between two rotations.
      Parameters:
      a - The start rotation.
      b - The end rotation.
      t - The interpolation factor (0.0 - 1.0).
      Returns:
      the interpolated rotation.
    • lerpUnclamped

      @Nonnull public static Rotation3f lerpUnclamped(@Nonnull Rotation3f a, @Nonnull Rotation3f b, float t)
      Called to linearly interpolate between two rotations without clamping.
      Parameters:
      a - The start rotation.
      b - The end rotation.
      t - The interpolation factor.
      Returns:
      the interpolated rotation.
    • lerpAngle

      @Nonnull public static Rotation3f lerpAngle(@Nonnull Rotation3fc a, @Nonnull Rotation3fc b, float t)
      Called to linearly interpolate between two angles.
      Parameters:
      a - The start rotation.
      b - The end rotation.
      t - The interpolation factor.
      Returns:
      the interpolated rotation.
    • lerpAngle

      @Nonnull public static Rotation3f lerpAngle(@Nonnull Rotation3fc a, @Nonnull Rotation3fc b, float t, @Nonnull Rotation3f target)
      Called to linearly interpolate between two angles and store it in a target rotation.
      Parameters:
      a - The start rotation.
      b - The end rotation.
      t - The interpolation factor.
      target - The target rotation.
      Returns:
      the interpolated rotation.
    • lookAt

      @Nonnull public static Rotation3f lookAt(@Nonnull org.joml.Vector3dc eye, @Nonnull org.joml.Vector3dc target)
      Called to compute the look at rotation from an eye position to a target position.
      Parameters:
      eye - The position looking.
      target - The position being looked at.
      Returns:
      the look at rotation.
    • lookAt

      @Nonnull public static Rotation3f lookAt(@Nonnull org.joml.Vector3dc eye, @Nonnull org.joml.Vector3dc target, @Nonnull Rotation3f result)
      Called to compute the look at rotation from an eye position to a target position and store it in a result rotation.
      Parameters:
      eye - The position looking.
      target - The position being looked at.
      result - The result rotation.
      Returns:
      the look at rotation.
    • lookAt

      @Nonnull public static Rotation3f lookAt(@Nonnull org.joml.Vector3dc relative)
      Called to compute the look at rotation for a relative rotation.
      Parameters:
      relative - The relative rotation.
      Returns:
      the look at rotation.
    • lookAt

      @Nonnull public static Rotation3f lookAt(@Nonnull org.joml.Vector3dc relative, @Nonnull Rotation3f result)
      Called to compute the look at rotation for a relative rotation and store it in a result rotation.
      Parameters:
      relative - The relative rotation.
      result - The result rotation.
      Returns:
      the look at rotation.
    • lookAt

      @Nonnull public static Rotation3f lookAt(double dx, double dy, double dz)
      Called to compute the look at rotation for a relative direction.
      Parameters:
      dx - The relative x component.
      dy - The relative y component.
      dz - The relative z component.
      Returns:
      the look at rotation.
    • lookAt

      @Nonnull public static Rotation3f lookAt(double dx, double dy, double dz, @Nonnull Rotation3f result)
      Called to compute the look at rotation for a relative direction and store it in a result rotation.
      Parameters:
      dx - The relative x component.
      dy - The relative y component.
      dz - The relative z component.
      result - The result rotation.
      Returns:
      the look at rotation