Class Quaternion

  • All Implemented Interfaces:
    java.io.Serializable

    public class Quaternion
    extends java.lang.Object
    implements java.io.Serializable
    A quaternion is q = w + x*i + y*j + z*k where (w,x,y,z) is not necessarily a unit length vector in 4D.
    See Also:
    Serialized Form
    • Field Detail

      • IDENTITY

        public static final Quaternion IDENTITY
      • ms_iNext

        private static int[] ms_iNext
        support for FromRotationMatrix
      • m_afTuple

        private float[] m_afTuple
    • Constructor Detail

      • Quaternion

        public Quaternion()
        construction: uninitialized
      • Quaternion

        public Quaternion​(float fW,
                          float fX,
                          float fY,
                          float fZ)
      • Quaternion

        public Quaternion​(Matrix3f rkRot)
        quaternion for the input rotation matrix
      • Quaternion

        public Quaternion​(Quaternion rkQ)
      • Quaternion

        public Quaternion​(Vector3f rkAxis,
                          float fAngle)
        quaternion for the rotation of the axis-angle pair
      • Quaternion

        public Quaternion​(Vector3f[] akRotColumn)
        quaternion for the rotation matrix with specified columns
    • Method Detail

      • Align

        public void Align​(Vector3f rkV1,
                          Vector3f rkV2)
        Compute a quaternion that rotates unit-length vector V1 to unit-length vector V2. The rotation is about the axis perpendicular to both V1 and V2, with angle of that between V1 and V2. If V1 and V2 are parallel, any axis of rotation will do, such as the permutation (z2,x2,y2), where V2 = (x2,y2,z2).
      • Dot

        public final float Dot​(Quaternion rkQ)
      • FromAxisAngle

        public void FromAxisAngle​(Vector3f rkAxis,
                                  float fAngle)
      • FromRotationMatrix

        public void FromRotationMatrix​(Matrix3f rkRot)
      • FromRotationMatrix

        public void FromRotationMatrix​(Vector3f[] akRotColumn)
      • Normalize

        public final void Normalize()
        Normalizes the value of this quaternion in place.
      • Scale

        public final Quaternion Scale​(float fScalar)
      • ToAxisAngle

        public float ToAxisAngle​(Vector3f rkAxis)
      • ToRotationMatrix

        public void ToRotationMatrix​(Matrix3f rkRot)
      • ToRotationMatrix

        public void ToRotationMatrix​(Vector3f[] akRotColumn)
      • W

        public float W()
        Get the W-component.
        Returns:
        m_afTuple[0]
      • X

        public float X()
        Get the X-component
        Returns:
        m_afTuple[1]
      • Y

        public float Y()
        Get the Y-component
        Returns:
        m_afTuple[2]
      • Z

        public float Z()
        Get the Z-component
        Returns:
        m_afTuple[3]
      • Norm

        private final float Norm()
        Caculate the square length
        Returns:
        square length of the quaternion