Package limn.math

Record Class Transform3D

java.lang.Object
java.lang.Record
limn.math.Transform3D

public record Transform3D(Vec3 translation, Quat rotation, Vec3 scale) extends Record
A translation/rotation/scale transform, the human-friendly way to place a node in 3D. toMatrix() composes it into a model matrix (T·R·S).
  • Field Details

  • Constructor Details

    • Transform3D

      public Transform3D(Vec3 translation, Quat rotation, Vec3 scale)
      Creates an instance of a Transform3D record class.
      Parameters:
      translation - the value for the translation record component
      rotation - the value for the rotation record component
      scale - the value for the scale record component
  • Method Details

    • at

      public static Transform3D at(Vec3 translation)
      A transform with only a translation: no rotation, unit scale.
    • withTranslation

      public Transform3D withTranslation(Vec3 t)
      A copy with a different translation.
    • withRotation

      public Transform3D withRotation(Quat r)
      A copy with a different rotation.
    • withScale

      public Transform3D withScale(Vec3 s)
      A copy with a different scale.
    • toMatrix

      public Mat4 toMatrix()
      The composed matrix, applied scale first, then rotation, then translation.
    • 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 Objects::equals(Object,Object).
      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.
    • translation

      public Vec3 translation()
      Returns the value of the translation record component.
      Returns:
      the value of the translation record component
    • rotation

      public Quat rotation()
      Returns the value of the rotation record component.
      Returns:
      the value of the rotation record component
    • scale

      public Vec3 scale()
      Returns the value of the scale record component.
      Returns:
      the value of the scale record component