Package org.joml

Class Quaternionf

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, Quaternionfc

    public class Quaternionf
    extends java.lang.Object
    implements java.io.Externalizable, java.lang.Cloneable, Quaternionfc
    Quaternion of 4 single-precision floats which can represent rotation and uniform scaling.
    Author:
    Richard Greenlees, Kai Burjack
    See Also:
    Serialized Form
    • Field Detail

      • x

        public float x
        The first component of the vector part.
      • y

        public float y
        The second component of the vector part.
      • z

        public float z
        The third component of the vector part.
      • w

        public float w
        The real/scalar part of the quaternion.
    • Constructor Detail

      • Quaternionf

        public Quaternionf()
        Create a new Quaternionf and initialize it with (x=0, y=0, z=0, w=1), where (x, y, z) is the vector part of the quaternion and w is the real/scalar part.
      • Quaternionf

        public Quaternionf​(double x,
                           double y,
                           double z,
                           double w)
        Create a new Quaternionf and initialize its components to the given values.
        Parameters:
        x - the first component of the imaginary part
        y - the second component of the imaginary part
        z - the third component of the imaginary part
        w - the real part
      • Quaternionf

        public Quaternionf​(float x,
                           float y,
                           float z,
                           float w)
        Create a new Quaternionf and initialize its components to the given values.
        Parameters:
        x - the first component of the imaginary part
        y - the second component of the imaginary part
        z - the third component of the imaginary part
        w - the real part
    • Method Detail

      • x

        public float x()
        Specified by:
        x in interface Quaternionfc
        Returns:
        the first component of the vector part
      • y

        public float y()
        Specified by:
        y in interface Quaternionfc
        Returns:
        the second component of the vector part
      • z

        public float z()
        Specified by:
        z in interface Quaternionfc
        Returns:
        the third component of the vector part
      • w

        public float w()
        Specified by:
        w in interface Quaternionfc
        Returns:
        the real/scalar part of the quaternion
      • normalize

        public Quaternionf normalize()
        Normalize this quaternion.
        Returns:
        this
      • normalize

        public Quaternionf normalize​(Quaternionf dest)
        Description copied from interface: Quaternionfc
        Normalize this quaternion and store the result in dest.
        Specified by:
        normalize in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • add

        public Quaternionf add​(float x,
                               float y,
                               float z,
                               float w)
        Add the quaternion (x, y, z, w) to this quaternion.
        Parameters:
        x - the x component of the vector part
        y - the y component of the vector part
        z - the z component of the vector part
        w - the real/scalar component
        Returns:
        this
      • add

        public Quaternionf add​(float x,
                               float y,
                               float z,
                               float w,
                               Quaternionf dest)
        Description copied from interface: Quaternionfc
        Add the quaternion (x, y, z, w) to this quaternion and store the result in dest.
        Specified by:
        add in interface Quaternionfc
        Parameters:
        x - the x component of the vector part
        y - the y component of the vector part
        z - the z component of the vector part
        w - the real/scalar component
        dest - will hold the result
        Returns:
        dest
      • add

        public Quaternionf add​(Quaternionfc q2)
        Add q2 to this quaternion.
        Parameters:
        q2 - the quaternion to add to this
        Returns:
        this
      • add

        public Quaternionf add​(Quaternionfc q2,
                               Quaternionf dest)
        Description copied from interface: Quaternionfc
        Add q2 to this quaternion and store the result in dest.
        Specified by:
        add in interface Quaternionfc
        Parameters:
        q2 - the quaternion to add to this
        dest - will hold the result
        Returns:
        dest
      • dot

        public float dot​(Quaternionf otherQuat)
        Return the dot of this quaternion and otherQuat.
        Parameters:
        otherQuat - the other quaternion
        Returns:
        the dot product
      • angle

        public float angle()
        Description copied from interface: Quaternionfc
        Return the angle in radians represented by this normalized quaternion rotation.

        This quaternion must be normalized.

        Specified by:
        angle in interface Quaternionfc
        Returns:
        the angle in radians
      • getAsMatrix3f

        public java.nio.ByteBuffer getAsMatrix3f​(java.nio.ByteBuffer dest)
        Description copied from interface: Quaternionfc
        Store the 3x3 float matrix representation of this quaternion in column-major order into the given ByteBuffer.

        This is equivalent to calling: this.get(new Matrix3f()).get(dest)

        Specified by:
        getAsMatrix3f in interface Quaternionfc
        Parameters:
        dest - the destination buffer
        Returns:
        dest
      • getAsMatrix3f

        public java.nio.FloatBuffer getAsMatrix3f​(java.nio.FloatBuffer dest)
        Description copied from interface: Quaternionfc
        Store the 3x3 float matrix representation of this quaternion in column-major order into the given FloatBuffer.

        This is equivalent to calling: this.get(new Matrix3f()).get(dest)

        Specified by:
        getAsMatrix3f in interface Quaternionfc
        Parameters:
        dest - the destination buffer
        Returns:
        dest
      • getAsMatrix4f

        public java.nio.ByteBuffer getAsMatrix4f​(java.nio.ByteBuffer dest)
        Description copied from interface: Quaternionfc
        Store the 4x4 float matrix representation of this quaternion in column-major order into the given ByteBuffer.

        This is equivalent to calling: this.get(new Matrix4f()).get(dest)

        Specified by:
        getAsMatrix4f in interface Quaternionfc
        Parameters:
        dest - the destination buffer
        Returns:
        dest
      • getAsMatrix4f

        public java.nio.FloatBuffer getAsMatrix4f​(java.nio.FloatBuffer dest)
        Description copied from interface: Quaternionfc
        Store the 4x4 float matrix representation of this quaternion in column-major order into the given FloatBuffer.

        This is equivalent to calling: this.get(new Matrix4f()).get(dest)

        Specified by:
        getAsMatrix4f in interface Quaternionfc
        Parameters:
        dest - the destination buffer
        Returns:
        dest
      • getAsMatrix4x3f

        public java.nio.ByteBuffer getAsMatrix4x3f​(java.nio.ByteBuffer dest)
        Description copied from interface: Quaternionfc
        Store the 4x3 float matrix representation of this quaternion in column-major order into the given ByteBuffer.

        This is equivalent to calling: this.get(new Matrix4x3f()).get(dest)

        Specified by:
        getAsMatrix4x3f in interface Quaternionfc
        Parameters:
        dest - the destination buffer
        Returns:
        dest
      • getAsMatrix4x3f

        public java.nio.FloatBuffer getAsMatrix4x3f​(java.nio.FloatBuffer dest)
        Description copied from interface: Quaternionfc
        Store the 4x3 float matrix representation of this quaternion in column-major order into the given FloatBuffer.

        This is equivalent to calling: this.get(new Matrix4x3f()).get(dest)

        Specified by:
        getAsMatrix4x3f in interface Quaternionfc
        Parameters:
        dest - the destination buffer
        Returns:
        dest
      • set

        public Quaternionf set​(float x,
                               float y,
                               float z,
                               float w)
        Set this quaternion to the given values.
        Parameters:
        x - the new value of x
        y - the new value of y
        z - the new value of z
        w - the new value of w
        Returns:
        this
      • setAngleAxis

        public Quaternionf setAngleAxis​(float angle,
                                        float x,
                                        float y,
                                        float z)
        Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).

        This method assumes that the given rotation axis (x, y, z) is already normalized

        Parameters:
        angle - the angle in radians
        x - the x-component of the normalized rotation axis
        y - the y-component of the normalized rotation axis
        z - the z-component of the normalized rotation axis
        Returns:
        this
      • setAngleAxis

        public Quaternionf setAngleAxis​(double angle,
                                        double x,
                                        double y,
                                        double z)
        Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).

        This method assumes that the given rotation axis (x, y, z) is already normalized

        Parameters:
        angle - the angle in radians
        x - the x-component of the normalized rotation axis
        y - the y-component of the normalized rotation axis
        z - the z-component of the normalized rotation axis
        Returns:
        this
      • rotationAxis

        public Quaternionf rotationAxis​(float angle,
                                        float axisX,
                                        float axisY,
                                        float axisZ)
        Set this quaternion to a rotation of the given angle in radians about the supplied axis.
        Parameters:
        angle - the rotation angle in radians
        axisX - the x-coordinate of the rotation axis
        axisY - the y-coordinate of the rotation axis
        axisZ - the z-coordinate of the rotation axis
        Returns:
        this
      • rotationAxis

        public Quaternionf rotationAxis​(float angle,
                                        Vector3fc axis)
        Set this quaternion to a rotation of the given angle in radians about the supplied axis.
        Parameters:
        angle - the rotation angle in radians
        axis - the axis to rotate about
        Returns:
        this
        See Also:
        rotationAxis(float, float, float, float)
      • rotationX

        public Quaternionf rotationX​(float angle)
        Set this quaternion to represent a rotation of the given radians about the x axis.
        Parameters:
        angle - the angle in radians to rotate about the x axis
        Returns:
        this
      • rotationY

        public Quaternionf rotationY​(float angle)
        Set this quaternion to represent a rotation of the given radians about the y axis.
        Parameters:
        angle - the angle in radians to rotate about the y axis
        Returns:
        this
      • rotationZ

        public Quaternionf rotationZ​(float angle)
        Set this quaternion to represent a rotation of the given radians about the z axis.
        Parameters:
        angle - the angle in radians to rotate about the z axis
        Returns:
        this
      • setFromUnnormalized

        public Quaternionf setFromUnnormalized​(Matrix4fc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromUnnormalized

        public Quaternionf setFromUnnormalized​(Matrix4x3fc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromUnnormalized

        public Quaternionf setFromUnnormalized​(Matrix4x3dc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromNormalized

        public Quaternionf setFromNormalized​(Matrix4fc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromNormalized

        public Quaternionf setFromNormalized​(Matrix4x3fc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromNormalized

        public Quaternionf setFromNormalized​(Matrix4x3dc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromUnnormalized

        public Quaternionf setFromUnnormalized​(Matrix4dc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromNormalized

        public Quaternionf setFromNormalized​(Matrix4dc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromUnnormalized

        public Quaternionf setFromUnnormalized​(Matrix3fc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromNormalized

        public Quaternionf setFromNormalized​(Matrix3fc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromUnnormalized

        public Quaternionf setFromUnnormalized​(Matrix3dc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.

        This method assumes that the first three columns of the upper left 3x3 submatrix are no unit vectors.

        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • setFromNormalized

        public Quaternionf setFromNormalized​(Matrix3dc mat)
        Set this quaternion to be a representation of the rotational component of the given matrix.
        Parameters:
        mat - the matrix whose rotational component is used to set this quaternion
        Returns:
        this
      • fromAxisAngleRad

        public Quaternionf fromAxisAngleRad​(Vector3fc axis,
                                            float angle)
        Set this quaternion to be a representation of the supplied axis and angle (in radians).
        Parameters:
        axis - the rotation axis
        angle - the angle in radians
        Returns:
        this
      • fromAxisAngleRad

        public Quaternionf fromAxisAngleRad​(float axisX,
                                            float axisY,
                                            float axisZ,
                                            float angle)
        Set this quaternion to be a representation of the supplied axis and angle (in radians).
        Parameters:
        axisX - the x component of the rotation axis
        axisY - the y component of the rotation axis
        axisZ - the z component of the rotation axis
        angle - the angle in radians
        Returns:
        this
      • fromAxisAngleDeg

        public Quaternionf fromAxisAngleDeg​(Vector3fc axis,
                                            float angle)
        Set this quaternion to be a representation of the supplied axis and angle (in degrees).
        Parameters:
        axis - the rotation axis
        angle - the angle in degrees
        Returns:
        this
      • fromAxisAngleDeg

        public Quaternionf fromAxisAngleDeg​(float axisX,
                                            float axisY,
                                            float axisZ,
                                            float angle)
        Set this quaternion to be a representation of the supplied axis and angle (in degrees).
        Parameters:
        axisX - the x component of the rotation axis
        axisY - the y component of the rotation axis
        axisZ - the z component of the rotation axis
        angle - the angle in radians
        Returns:
        this
      • mul

        public Quaternionf mul​(Quaternionfc q)
        Multiply this quaternion by q.

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

        R = T * Q

        So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by Q first, and then by T.

        Parameters:
        q - the quaternion to multiply this by
        Returns:
        this
      • mul

        public Quaternionf mul​(Quaternionfc q,
                               Quaternionf dest)
        Description copied from interface: Quaternionfc
        Multiply this quaternion 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

        So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by Q first, and then by T.

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

        public Quaternionf mul​(float qx,
                               float qy,
                               float qz,
                               float qw)
        Multiply this quaternion by the quaternion represented via (qx, qy, qz, qw).

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

        R = T * Q

        So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by Q first, and then by T.

        Parameters:
        qx - the x component of the quaternion to multiply this by
        qy - the y component of the quaternion to multiply this by
        qz - the z component of the quaternion to multiply this by
        qw - the w component of the quaternion to multiply this by
        Returns:
        this
      • mul

        public Quaternionf mul​(float qx,
                               float qy,
                               float qz,
                               float qw,
                               Quaternionf dest)
        Description copied from interface: Quaternionfc
        Multiply this quaternion by the quaternion represented via (qx, qy, qz, qw) 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

        So, this method uses post-multiplication like the matrix classes, resulting in a vector to be transformed by Q first, and then by T.

        Specified by:
        mul in interface Quaternionfc
        Parameters:
        qx - the x component of the quaternion to multiply this by
        qy - the y component of the quaternion to multiply this by
        qz - the z component of the quaternion to multiply this by
        qw - the w component of the quaternion to multiply this by
        dest - will hold the result
        Returns:
        dest
      • mul

        public Quaternionf mul​(float f)
        Multiply this quaternion by the given scalar.

        This method multiplies all of the four components by the specified scalar.

        Parameters:
        f - the factor to multiply all components by
        Returns:
        this
      • mul

        public Quaternionf mul​(float f,
                               Quaternionf dest)
        Description copied from interface: Quaternionfc
        Multiply this quaternion by the given scalar and store the result in dest.

        This method multiplies all of the four components by the specified scalar.

        Specified by:
        mul in interface Quaternionfc
        Parameters:
        f - the factor to multiply all components by
        dest - will hold the result
        Returns:
        dest
      • premul

        public Quaternionf premul​(Quaternionfc q)
        Pre-multiply this quaternion by q.

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

        R = Q * T

        So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.

        Parameters:
        q - the quaternion to pre-multiply this by
        Returns:
        this
      • premul

        public Quaternionf premul​(Quaternionfc q,
                                  Quaternionf dest)
        Description copied from interface: Quaternionfc
        Pre-multiply this quaternion 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

        So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.

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

        public Quaternionf premul​(float qx,
                                  float qy,
                                  float qz,
                                  float qw)
        Pre-multiply this quaternion by the quaternion represented via (qx, qy, qz, qw).

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

        R = Q * T

        So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.

        Parameters:
        qx - the x component of the quaternion to multiply this by
        qy - the y component of the quaternion to multiply this by
        qz - the z component of the quaternion to multiply this by
        qw - the w component of the quaternion to multiply this by
        Returns:
        this
      • premul

        public Quaternionf premul​(float qx,
                                  float qy,
                                  float qz,
                                  float qw,
                                  Quaternionf dest)
        Description copied from interface: Quaternionfc
        Pre-multiply this quaternion by the quaternion represented via (qx, qy, qz, qw) 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

        So, this method uses pre-multiplication, resulting in a vector to be transformed by T first, and then by Q.

        Specified by:
        premul in interface Quaternionfc
        Parameters:
        qx - the x component of the quaternion to multiply this by
        qy - the y component of the quaternion to multiply this by
        qz - the z component of the quaternion to multiply this by
        qw - the w component of the quaternion to multiply this by
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector3f transform​(Vector3f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverse

        public Vector3f transformInverse​(Vector3f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformPositiveX

        public Vector3f transformPositiveX​(Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (1, 0, 0) by this quaternion.
        Specified by:
        transformPositiveX in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveX

        public Vector4f transformPositiveX​(Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (1, 0, 0) by this quaternion.

        Only the first three components of the given 4D vector are modified.

        Specified by:
        transformPositiveX in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveX

        public Vector4f transformUnitPositiveX​(Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (1, 0, 0) by this unit quaternion.

        Only the first three components of the given 4D vector are modified.

        This method is only applicable when this is a unit quaternion.

        Reference: https://de.mathworks.com/

        Specified by:
        transformUnitPositiveX in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveY

        public Vector3f transformPositiveY​(Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 1, 0) by this quaternion.
        Specified by:
        transformPositiveY in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveY

        public Vector4f transformPositiveY​(Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 1, 0) by this quaternion.

        Only the first three components of the given 4D vector are modified.

        Specified by:
        transformPositiveY in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveY

        public Vector4f transformUnitPositiveY​(Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 1, 0) by this unit quaternion.

        Only the first three components of the given 4D vector are modified.

        This method is only applicable when this is a unit quaternion.

        Reference: https://de.mathworks.com/

        Specified by:
        transformUnitPositiveY in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveZ

        public Vector3f transformPositiveZ​(Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 0, 1) by this quaternion.
        Specified by:
        transformPositiveZ in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveZ

        public Vector4f transformPositiveZ​(Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 0, 1) by this quaternion.

        Only the first three components of the given 4D vector are modified.

        Specified by:
        transformPositiveZ in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveZ

        public Vector4f transformUnitPositiveZ​(Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 0, 1) by this unit quaternion.

        Only the first three components of the given 4D vector are modified.

        This method is only applicable when this is a unit quaternion.

        Reference: https://de.mathworks.com/

        Specified by:
        transformUnitPositiveZ in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector4f transform​(Vector4f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion.

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

        Only the first three components of the given 4D vector are being used and modified.

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverse

        public Vector4f transformInverse​(Vector4f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion.

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

        Only the first three components of the given 4D vector are being used and modified.

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transform

        public Vector3f transform​(Vector3fc vec,
                                  Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion and store the result in dest.

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

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

        public Vector3f transformInverse​(Vector3fc vec,
                                         Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of quaternion and store the result in dest.

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

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

        public Vector3f transform​(float x,
                                  float y,
                                  float z,
                                  Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this quaternion and store the result in dest.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverse

        public Vector3f transformInverse​(float x,
                                         float y,
                                         float z,
                                         Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this quaternion and store the result in dest.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformUnit

        public Vector3f transformUnit​(Vector3f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverseUnit

        public Vector3f transformInverseUnit​(Vector3f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformUnit

        public Vector3f transformUnit​(Vector3fc vec,
                                      Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

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

        public Vector3f transformInverseUnit​(Vector3fc vec,
                                             Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

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

        public Vector3f transformUnit​(float x,
                                      float y,
                                      float z,
                                      Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverseUnit

        public Vector3f transformInverseUnit​(float x,
                                             float y,
                                             float z,
                                             Vector3f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector4f transform​(Vector4fc vec,
                                  Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

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

        public Vector4f transformInverse​(Vector4fc vec,
                                         Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

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

        public Vector4f transform​(float x,
                                  float y,
                                  float z,
                                  Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this quaternion and store the result in dest.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverse

        public Vector4f transformInverse​(float x,
                                         float y,
                                         float z,
                                         Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this quaternion and store the result in dest.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector3d transform​(Vector3d vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverse

        public Vector3d transformInverse​(Vector3d vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformUnit

        public Vector4f transformUnit​(Vector4f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverseUnit

        public Vector4f transformInverseUnit​(Vector4f vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformUnit

        public Vector4f transformUnit​(Vector4fc vec,
                                      Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

        This method is only applicable when this is a unit quaternion.

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

        public Vector4f transformInverseUnit​(Vector4fc vec,
                                             Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

        This method is only applicable when this is a unit quaternion.

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

        public Vector4f transformUnit​(float x,
                                      float y,
                                      float z,
                                      Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverseUnit

        public Vector4f transformInverseUnit​(float x,
                                             float y,
                                             float z,
                                             Vector4f dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformPositiveX

        public Vector3d transformPositiveX​(Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (1, 0, 0) by this quaternion.
        Specified by:
        transformPositiveX in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveX

        public Vector4d transformPositiveX​(Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (1, 0, 0) by this quaternion.

        Only the first three components of the given 4D vector are modified.

        Specified by:
        transformPositiveX in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveX

        public Vector4d transformUnitPositiveX​(Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (1, 0, 0) by this unit quaternion.

        Only the first three components of the given 4D vector are modified.

        This method is only applicable when this is a unit quaternion.

        Reference: https://de.mathworks.com/

        Specified by:
        transformUnitPositiveX in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveY

        public Vector3d transformPositiveY​(Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 1, 0) by this quaternion.
        Specified by:
        transformPositiveY in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveY

        public Vector4d transformPositiveY​(Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 1, 0) by this quaternion.

        Only the first three components of the given 4D vector are modified.

        Specified by:
        transformPositiveY in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveY

        public Vector4d transformUnitPositiveY​(Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 1, 0) by this unit quaternion.

        Only the first three components of the given 4D vector are modified.

        This method is only applicable when this is a unit quaternion.

        Reference: https://de.mathworks.com/

        Specified by:
        transformUnitPositiveY in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveZ

        public Vector3d transformPositiveZ​(Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 0, 1) by this quaternion.
        Specified by:
        transformPositiveZ in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveZ

        public Vector4d transformPositiveZ​(Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 0, 1) by this quaternion.

        Only the first three components of the given 4D vector are modified.

        Specified by:
        transformPositiveZ in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveZ

        public Vector4d transformUnitPositiveZ​(Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the vector (0, 0, 1) by this unit quaternion.

        Only the first three components of the given 4D vector are modified.

        This method is only applicable when this is a unit quaternion.

        Reference: https://de.mathworks.com/

        Specified by:
        transformUnitPositiveZ in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector4d transform​(Vector4d vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion.

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

        Only the first three components of the given 4D vector are being used and modified.

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverse

        public Vector4d transformInverse​(Vector4d vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion.

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

        Only the first three components of the given 4D vector are being used and modified.

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transform

        public Vector3d transform​(Vector3dc vec,
                                  Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion and store the result in dest.

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

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

        public Vector3d transformInverse​(Vector3dc vec,
                                         Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion and store the result in dest.

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

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

        public Vector3d transform​(float x,
                                  float y,
                                  float z,
                                  Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this quaternion and store the result in dest.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverse

        public Vector3d transformInverse​(float x,
                                         float y,
                                         float z,
                                         Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this quaternion and store the result in dest.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector3d transform​(double x,
                                  double y,
                                  double z,
                                  Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this quaternion and store the result in dest.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverse

        public Vector3d transformInverse​(double x,
                                         double y,
                                         double z,
                                         Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this quaternion and store the result in dest.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector4d transform​(Vector4dc vec,
                                  Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

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

        public Vector4d transformInverse​(Vector4dc vec,
                                         Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

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

        public Vector4d transform​(double x,
                                  double y,
                                  double z,
                                  Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this quaternion and store the result in dest.

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

        Specified by:
        transform in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverse

        public Vector4d transformInverse​(double x,
                                         double y,
                                         double z,
                                         Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this quaternion and store the result in dest.

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

        Specified by:
        transformInverse in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformUnit

        public Vector4d transformUnit​(Vector4d vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion.

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

        Only the first three components of the given 4D vector are being used and modified.

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformInverseUnit

        public Vector4d transformInverseUnit​(Vector4d vec)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion.

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

        Only the first three components of the given 4D vector are being used and modified.

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformUnit

        public Vector3d transformUnit​(Vector3dc vec,
                                      Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

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

        public Vector3d transformInverseUnit​(Vector3dc vec,
                                             Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

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

        public Vector3d transformUnit​(float x,
                                      float y,
                                      float z,
                                      Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverseUnit

        public Vector3d transformInverseUnit​(float x,
                                             float y,
                                             float z,
                                             Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformUnit

        public Vector3d transformUnit​(double x,
                                      double y,
                                      double z,
                                      Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverseUnit

        public Vector3d transformInverseUnit​(double x,
                                             double y,
                                             double z,
                                             Vector3d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformUnit

        public Vector4d transformUnit​(Vector4dc vec,
                                      Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by this unit quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

        This method is only applicable when this is a unit quaternion.

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

        public Vector4d transformInverseUnit​(Vector4dc vec,
                                             Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector by the inverse of this unit quaternion and store the result in dest.

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

        Only the first three components of the given 4D vector are being used and set on the destination.

        This method is only applicable when this is a unit quaternion.

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

        public Vector4d transformUnit​(double x,
                                      double y,
                                      double z,
                                      Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • transformInverseUnit

        public Vector4d transformInverseUnit​(double x,
                                             double y,
                                             double z,
                                             Vector4d dest)
        Description copied from interface: Quaternionfc
        Transform the given vector (x, y, z) by the inverse of this unit quaternion and store the result in dest.

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

        This method is only applicable when this is a unit quaternion.

        Specified by:
        transformInverseUnit in interface Quaternionfc
        Parameters:
        x - the x coordinate of the vector to transform
        y - the y coordinate of the vector to transform
        z - the z coordinate of the vector to transform
        dest - will hold the result
        Returns:
        dest
      • div

        public Quaternionf div​(Quaternionfc b,
                               Quaternionf dest)
        Description copied from interface: Quaternionfc
        Divide this quaternion by b and store the result in dest.

        The division expressed using the inverse is performed in the following way:

        dest = this * b^-1, where b^-1 is the inverse of b.

        Specified by:
        div in interface Quaternionfc
        Parameters:
        b - the Quaternionfc to divide this by
        dest - will hold the result
        Returns:
        dest
      • div

        public Quaternionf div​(Quaternionfc b)
        Divide this quaternion by b.

        The division expressed using the inverse is performed in the following way:

        this = this * b^-1, where b^-1 is the inverse of b.

        Parameters:
        b - the Quaternionf to divide this by
        Returns:
        this
      • conjugate

        public Quaternionf conjugate()
        Conjugate this quaternion.
        Returns:
        this
      • conjugate

        public Quaternionf conjugate​(Quaternionf dest)
        Description copied from interface: Quaternionfc
        Conjugate this quaternion and store the result in dest.
        Specified by:
        conjugate in interface Quaternionfc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • identity

        public Quaternionf identity()
        Set this quaternion to the identity.
        Returns:
        this
      • rotateXYZ

        public Quaternionf rotateXYZ​(float angleX,
                                     float angleY,
                                     float angleZ)
        Apply a rotation to this quaternion rotating the given radians about the cartesian base unit axes, called the euler angles using rotation sequence XYZ.

        This method is equivalent to calling: rotateX(angleX).rotateY(angleY).rotateZ(angleZ)

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angleX - the angle in radians to rotate about the x axis
        angleY - the angle in radians to rotate about the y axis
        angleZ - the angle in radians to rotate about the z axis
        Returns:
        this
      • rotateXYZ

        public Quaternionf rotateXYZ​(float angleX,
                                     float angleY,
                                     float angleZ,
                                     Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the cartesian base unit axes, called the euler angles using rotation sequence XYZ and store the result in dest.

        This method is equivalent to calling: rotateX(angleX, dest).rotateY(angleY).rotateZ(angleZ)

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateXYZ in interface Quaternionfc
        Parameters:
        angleX - the angle in radians to rotate about the x axis
        angleY - the angle in radians to rotate about the y axis
        angleZ - the angle in radians to rotate about the z axis
        dest - will hold the result
        Returns:
        dest
      • rotateZYX

        public Quaternionf rotateZYX​(float angleZ,
                                     float angleY,
                                     float angleX)
        Apply a rotation to this quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequence ZYX.

        This method is equivalent to calling: rotateZ(angleZ).rotateY(angleY).rotateX(angleX)

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angleZ - the angle in radians to rotate about the z axis
        angleY - the angle in radians to rotate about the y axis
        angleX - the angle in radians to rotate about the x axis
        Returns:
        this
      • rotateZYX

        public Quaternionf rotateZYX​(float angleZ,
                                     float angleY,
                                     float angleX,
                                     Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequence ZYX and store the result in dest.

        This method is equivalent to calling: rotateZ(angleZ, dest).rotateY(angleY).rotateX(angleX)

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateZYX in interface Quaternionfc
        Parameters:
        angleZ - the angle in radians to rotate about the z axis
        angleY - the angle in radians to rotate about the y axis
        angleX - the angle in radians to rotate about the x axis
        dest - will hold the result
        Returns:
        dest
      • rotateYXZ

        public Quaternionf rotateYXZ​(float angleY,
                                     float angleX,
                                     float angleZ)
        Apply a rotation to this quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequence YXZ.

        This method is equivalent to calling: rotateY(angleY).rotateX(angleX).rotateZ(angleZ)

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angleY - the angle in radians to rotate about the y axis
        angleX - the angle in radians to rotate about the x axis
        angleZ - the angle in radians to rotate about the z axis
        Returns:
        this
      • rotateYXZ

        public Quaternionf rotateYXZ​(float angleY,
                                     float angleX,
                                     float angleZ,
                                     Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the cartesian base unit axes, called the euler angles, using the rotation sequence YXZ and store the result in dest.

        This method is equivalent to calling: rotateY(angleY, dest).rotateX(angleX).rotateZ(angleZ)

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateYXZ in interface Quaternionfc
        Parameters:
        angleY - the angle in radians to rotate about the y axis
        angleX - the angle in radians to rotate about the x axis
        angleZ - the angle in radians to rotate about the z axis
        dest - will hold the result
        Returns:
        dest
      • getEulerAnglesXYZ

        public Vector3f getEulerAnglesXYZ​(Vector3f eulerAngles)
        Description copied from interface: Quaternionfc
        Get the euler angles in radians in rotation sequence XYZ of this quaternion and store them in the provided parameter eulerAngles.

        The Euler angles are always returned as the angle around X in the Vector3f.x field, the angle around Y in the Vector3f.y field and the angle around Z in the Vector3f.z field of the supplied Vector3f instance.

        Specified by:
        getEulerAnglesXYZ in interface Quaternionfc
        Parameters:
        eulerAngles - will hold the euler angles in radians
        Returns:
        the passed in vector
      • getEulerAnglesZYX

        public Vector3f getEulerAnglesZYX​(Vector3f eulerAngles)
        Description copied from interface: Quaternionfc
        Get the euler angles in radians in rotation sequence ZYX of this quaternion and store them in the provided parameter eulerAngles.

        The Euler angles are always returned as the angle around X in the Vector3f.x field, the angle around Y in the Vector3f.y field and the angle around Z in the Vector3f.z field of the supplied Vector3f instance.

        Specified by:
        getEulerAnglesZYX in interface Quaternionfc
        Parameters:
        eulerAngles - will hold the euler angles in radians
        Returns:
        the passed in vector
      • getEulerAnglesZXY

        public Vector3f getEulerAnglesZXY​(Vector3f eulerAngles)
        Description copied from interface: Quaternionfc
        Get the euler angles in radians in rotation sequence ZXY of this quaternion and store them in the provided parameter eulerAngles.

        The Euler angles are always returned as the angle around X in the Vector3f.x field, the angle around Y in the Vector3f.y field and the angle around Z in the Vector3f.z field of the supplied Vector3f instance.

        Specified by:
        getEulerAnglesZXY in interface Quaternionfc
        Parameters:
        eulerAngles - will hold the euler angles in radians
        Returns:
        the passed in vector
      • getEulerAnglesYXZ

        public Vector3f getEulerAnglesYXZ​(Vector3f eulerAngles)
        Description copied from interface: Quaternionfc
        Get the euler angles in radians in rotation sequence YXZ of this quaternion and store them in the provided parameter eulerAngles.

        The Euler angles are always returned as the angle around X in the Vector3f.x field, the angle around Y in the Vector3f.y field and the angle around Z in the Vector3f.z field of the supplied Vector3f instance.

        Specified by:
        getEulerAnglesYXZ in interface Quaternionfc
        Parameters:
        eulerAngles - will hold the euler angles in radians
        Returns:
        the passed in vector
      • lengthSquared

        public float lengthSquared()
        Description copied from interface: Quaternionfc
        Return the square of the length of this quaternion.
        Specified by:
        lengthSquared in interface Quaternionfc
        Returns:
        the length
      • rotationXYZ

        public Quaternionf rotationXYZ​(float angleX,
                                       float angleY,
                                       float angleZ)
        Set this quaternion from the supplied euler angles (in radians) with rotation order XYZ.

        This method is equivalent to calling: rotationX(angleX).rotateY(angleY).rotateZ(angleZ)

        Reference: this stackexchange answer

        Parameters:
        angleX - the angle in radians to rotate about x
        angleY - the angle in radians to rotate about y
        angleZ - the angle in radians to rotate about z
        Returns:
        this
      • rotationZYX

        public Quaternionf rotationZYX​(float angleZ,
                                       float angleY,
                                       float angleX)
        Set this quaternion from the supplied euler angles (in radians) with rotation order ZYX.

        This method is equivalent to calling: rotationZ(angleZ).rotateY(angleY).rotateX(angleX)

        Reference: this stackexchange answer

        Parameters:
        angleX - the angle in radians to rotate about x
        angleY - the angle in radians to rotate about y
        angleZ - the angle in radians to rotate about z
        Returns:
        this
      • rotationYXZ

        public Quaternionf rotationYXZ​(float angleY,
                                       float angleX,
                                       float angleZ)
        Set this quaternion from the supplied euler angles (in radians) with rotation order YXZ.

        This method is equivalent to calling: rotationY(angleY).rotateX(angleX).rotateZ(angleZ)

        Reference: https://en.wikipedia.org

        Parameters:
        angleY - the angle in radians to rotate about y
        angleX - the angle in radians to rotate about x
        angleZ - the angle in radians to rotate about z
        Returns:
        this
      • slerp

        public Quaternionf slerp​(Quaternionfc target,
                                 float alpha)
        Interpolate between this unit quaternion and the specified target unit quaternion using spherical linear interpolation using the specified interpolation factor alpha.

        This method resorts to non-spherical linear interpolation when the absolute dot product of this and target is below 1E-6f.

        Parameters:
        target - the target of the interpolation, which should be reached with alpha = 1.0
        alpha - the interpolation factor, within [0..1]
        Returns:
        this
      • slerp

        public Quaternionf slerp​(Quaternionfc target,
                                 float alpha,
                                 Quaternionf dest)
        Description copied from interface: Quaternionfc
        Interpolate between this unit quaternion and the specified target unit quaternion using spherical linear interpolation using the specified interpolation factor alpha, and store the result in dest.

        This method resorts to non-spherical linear interpolation when the absolute dot product of this and target is below 1E-6f.

        Reference: http://fabiensanglard.net

        Specified by:
        slerp in interface Quaternionfc
        Parameters:
        target - the target of the interpolation, which should be reached with alpha = 1.0
        alpha - the interpolation factor, within [0..1]
        dest - will hold the result
        Returns:
        dest
      • slerp

        public static Quaternionfc slerp​(Quaternionf[] qs,
                                         float[] weights,
                                         Quaternionf dest)
        Interpolate between all of the quaternions given in qs via spherical linear interpolation using the specified interpolation factors weights, and store the result in dest.

        This method will interpolate between each two successive quaternions via slerp(Quaternionfc, float) using their relative interpolation weights.

        This method resorts to non-spherical linear interpolation when the absolute dot product of any two interpolated quaternions is below 1E-6f.

        Reference: http://gamedev.stackexchange.com/

        Parameters:
        qs - the quaternions to interpolate over
        weights - the weights of each individual quaternion in qs
        dest - will hold the result
        Returns:
        dest
      • scale

        public Quaternionf scale​(float factor)
        Apply scaling to this quaternion, which results in any vector transformed by this quaternion to change its length by the given factor.
        Parameters:
        factor - the scaling factor
        Returns:
        this
      • scale

        public Quaternionf scale​(float factor,
                                 Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply scaling to this quaternion, which results in any vector transformed by the quaternion to change its length by the given factor, and store the result in dest.
        Specified by:
        scale in interface Quaternionfc
        Parameters:
        factor - the scaling factor
        dest - will hold the result
        Returns:
        dest
      • scaling

        public Quaternionf scaling​(float factor)
        Set this quaternion to represent scaling, which results in a transformed vector to change its length by the given factor.
        Parameters:
        factor - the scaling factor
        Returns:
        this
      • integrate

        public Quaternionf integrate​(float dt,
                                     float vx,
                                     float vy,
                                     float vz)
        Integrate the rotation given by the angular velocity (vx, vy, vz) around the x, y and z axis, respectively, with respect to the given elapsed time delta dt and add the differentiate rotation to the rotation represented by this quaternion.

        This method pre-multiplies the rotation given by dt and (vx, vy, vz) by this, so the angular velocities are always relative to the local coordinate system of the rotation represented by this quaternion.

        This method is equivalent to calling: rotateLocal(dt * vx, dt * vy, dt * vz)

        Reference: http://physicsforgames.blogspot.de/

        Parameters:
        dt - the delta time
        vx - the angular velocity around the x axis
        vy - the angular velocity around the y axis
        vz - the angular velocity around the z axis
        Returns:
        this
      • integrate

        public Quaternionf integrate​(float dt,
                                     float vx,
                                     float vy,
                                     float vz,
                                     Quaternionf dest)
        Description copied from interface: Quaternionfc
        Integrate the rotation given by the angular velocity (vx, vy, vz) around the x, y and z axis, respectively, with respect to the given elapsed time delta dt and add the differentiate rotation to the rotation represented by this quaternion and store the result into dest.

        This method pre-multiplies the rotation given by dt and (vx, vy, vz) by this, so the angular velocities are always relative to the local coordinate system of the rotation represented by this quaternion.

        This method is equivalent to calling: rotateLocal(dt * vx, dt * vy, dt * vz, dest)

        Reference: http://physicsforgames.blogspot.de/

        Specified by:
        integrate in interface Quaternionfc
        Parameters:
        dt - the delta time
        vx - the angular velocity around the x axis
        vy - the angular velocity around the y axis
        vz - the angular velocity around the z axis
        dest - will hold the result
        Returns:
        dest
      • nlerp

        public Quaternionf nlerp​(Quaternionfc q,
                                 float factor)
        Compute a linear (non-spherical) interpolation of this and the given quaternion q and store the result in this.
        Parameters:
        q - the other quaternion
        factor - the interpolation factor. It is between 0.0 and 1.0
        Returns:
        this
      • nlerp

        public Quaternionf nlerp​(Quaternionfc q,
                                 float factor,
                                 Quaternionf dest)
        Description copied from interface: Quaternionfc
        Compute a linear (non-spherical) interpolation of this and the given quaternion q and store the result in dest.

        Reference: http://fabiensanglard.net

        Specified by:
        nlerp in interface Quaternionfc
        Parameters:
        q - the other quaternion
        factor - the interpolation factor. It is between 0.0 and 1.0
        dest - will hold the result
        Returns:
        dest
      • nlerp

        public static Quaternionfc nlerp​(Quaternionfc[] qs,
                                         float[] weights,
                                         Quaternionf dest)
        Interpolate between all of the quaternions given in qs via non-spherical linear interpolation using the specified interpolation factors weights, and store the result in dest.

        This method will interpolate between each two successive quaternions via nlerp(Quaternionfc, float) using their relative interpolation weights.

        Reference: http://gamedev.stackexchange.com/

        Parameters:
        qs - the quaternions to interpolate over
        weights - the weights of each individual quaternion in qs
        dest - will hold the result
        Returns:
        dest
      • nlerpIterative

        public Quaternionf nlerpIterative​(Quaternionfc q,
                                          float alpha,
                                          float dotThreshold,
                                          Quaternionf dest)
        Description copied from interface: Quaternionfc
        Compute linear (non-spherical) interpolations of this and the given quaternion q iteratively and store the result in dest.

        This method performs a series of small-step nlerp interpolations to avoid doing a costly spherical linear interpolation, like slerp, by subdividing the rotation arc between this and q via non-spherical linear interpolations as long as the absolute dot product of this and q is greater than the given dotThreshold parameter.

        Thanks to @theagentd at http://www.java-gaming.org/ for providing the code.

        Specified by:
        nlerpIterative in interface Quaternionfc
        Parameters:
        q - the other quaternion
        alpha - the interpolation factor, between 0.0 and 1.0
        dotThreshold - the threshold for the dot product of this and q above which this method performs another iteration of a small-step linear interpolation
        dest - will hold the result
        Returns:
        dest
      • nlerpIterative

        public Quaternionf nlerpIterative​(Quaternionfc q,
                                          float alpha,
                                          float dotThreshold)
        Compute linear (non-spherical) interpolations of this and the given quaternion q iteratively and store the result in this.

        This method performs a series of small-step nlerp interpolations to avoid doing a costly spherical linear interpolation, like slerp, by subdividing the rotation arc between this and q via non-spherical linear interpolations as long as the absolute dot product of this and q is greater than the given dotThreshold parameter.

        Thanks to @theagentd at http://www.java-gaming.org/ for providing the code.

        Parameters:
        q - the other quaternion
        alpha - the interpolation factor, between 0.0 and 1.0
        dotThreshold - the threshold for the dot product of this and q above which this method performs another iteration of a small-step linear interpolation
        Returns:
        this
      • nlerpIterative

        public static Quaternionfc nlerpIterative​(Quaternionf[] qs,
                                                  float[] weights,
                                                  float dotThreshold,
                                                  Quaternionf dest)
        Interpolate between all of the quaternions given in qs via iterative non-spherical linear interpolation using the specified interpolation factors weights, and store the result in dest.

        This method will interpolate between each two successive quaternions via nlerpIterative(Quaternionfc, float, float) using their relative interpolation weights.

        Reference: http://gamedev.stackexchange.com/

        Parameters:
        qs - the quaternions to interpolate over
        weights - the weights of each individual quaternion in qs
        dotThreshold - the threshold for the dot product of each two interpolated quaternions above which nlerpIterative(Quaternionfc, float, float) performs another iteration of a small-step linear interpolation
        dest - will hold the result
        Returns:
        dest
      • lookAlong

        public Quaternionf lookAlong​(Vector3fc dir,
                                     Vector3fc up)
        Apply a rotation to this quaternion that maps the given direction to the positive Z axis.

        Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the up and dir vectors.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Reference: http://answers.unity3d.com

        Parameters:
        dir - the direction to map to the positive Z axis
        up - the vector which will be mapped to a vector parallel to the plane spanned by the given dir and up
        Returns:
        this
        See Also:
        lookAlong(float, float, float, float, float, float, Quaternionf)
      • lookAlong

        public Quaternionf lookAlong​(Vector3fc dir,
                                     Vector3fc up,
                                     Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result in dest.

        Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the up and dir vectors.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Reference: http://answers.unity3d.com

        Specified by:
        lookAlong in interface Quaternionfc
        Parameters:
        dir - the direction to map to the positive Z axis
        up - the vector which will be mapped to a vector parallel to the plane spanned by the given dir and up
        dest - will hold the result
        Returns:
        dest
        See Also:
        Quaternionfc.lookAlong(float, float, float, float, float, float, Quaternionf)
      • lookAlong

        public Quaternionf lookAlong​(float dirX,
                                     float dirY,
                                     float dirZ,
                                     float upX,
                                     float upY,
                                     float upZ)
        Apply a rotation to this quaternion that maps the given direction to the positive Z axis.

        Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the up and dir vectors.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Reference: http://answers.unity3d.com

        Parameters:
        dirX - the x-coordinate of the direction to look along
        dirY - the y-coordinate of the direction to look along
        dirZ - the z-coordinate of the direction to look along
        upX - the x-coordinate of the up vector
        upY - the y-coordinate of the up vector
        upZ - the z-coordinate of the up vector
        Returns:
        this
        See Also:
        lookAlong(float, float, float, float, float, float, Quaternionf)
      • lookAlong

        public Quaternionf lookAlong​(float dirX,
                                     float dirY,
                                     float dirZ,
                                     float upX,
                                     float upY,
                                     float upZ,
                                     Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result in dest.

        Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain parallel to the plane spanned by the up and dir vectors.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Reference: http://answers.unity3d.com

        Specified by:
        lookAlong in interface Quaternionfc
        Parameters:
        dirX - the x-coordinate of the direction to look along
        dirY - the y-coordinate of the direction to look along
        dirZ - the z-coordinate of the direction to look along
        upX - the x-coordinate of the up vector
        upY - the y-coordinate of the up vector
        upZ - the z-coordinate of the up vector
        dest - will hold the result
        Returns:
        dest
      • rotationTo

        public Quaternionf rotationTo​(float fromDirX,
                                      float fromDirY,
                                      float fromDirZ,
                                      float toDirX,
                                      float toDirY,
                                      float toDirZ)
        Set this quaternion to a rotation that rotates the fromDir vector to point along toDir.

        Since there can be multiple possible rotations, this method chooses the one with the shortest arc.

        Reference: stackoverflow.com

        Parameters:
        fromDirX - the x-coordinate of the direction to rotate into the destination direction
        fromDirY - the y-coordinate of the direction to rotate into the destination direction
        fromDirZ - the z-coordinate of the direction to rotate into the destination direction
        toDirX - the x-coordinate of the direction to rotate to
        toDirY - the y-coordinate of the direction to rotate to
        toDirZ - the z-coordinate of the direction to rotate to
        Returns:
        this
      • rotationTo

        public Quaternionf rotationTo​(Vector3fc fromDir,
                                      Vector3fc toDir)
        Set this quaternion to a rotation that rotates the fromDir vector to point along toDir.

        Because there can be multiple possible rotations, this method chooses the one with the shortest arc.

        Parameters:
        fromDir - the starting direction
        toDir - the destination direction
        Returns:
        this
        See Also:
        rotationTo(float, float, float, float, float, float)
      • rotateTo

        public Quaternionf rotateTo​(float fromDirX,
                                    float fromDirY,
                                    float fromDirZ,
                                    float toDirX,
                                    float toDirY,
                                    float toDirZ,
                                    Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this that rotates the fromDir vector to point along toDir and store the result in dest.

        Since there can be multiple possible rotations, this method chooses the one with the shortest arc.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Reference: stackoverflow.com

        Specified by:
        rotateTo in interface Quaternionfc
        Parameters:
        fromDirX - the x-coordinate of the direction to rotate into the destination direction
        fromDirY - the y-coordinate of the direction to rotate into the destination direction
        fromDirZ - the z-coordinate of the direction to rotate into the destination direction
        toDirX - the x-coordinate of the direction to rotate to
        toDirY - the y-coordinate of the direction to rotate to
        toDirZ - the z-coordinate of the direction to rotate to
        dest - will hold the result
        Returns:
        dest
      • rotateTo

        public Quaternionf rotateTo​(float fromDirX,
                                    float fromDirY,
                                    float fromDirZ,
                                    float toDirX,
                                    float toDirY,
                                    float toDirZ)
        Apply a rotation to this that rotates the fromDir vector to point along toDir.

        Since there can be multiple possible rotations, this method chooses the one with the shortest arc.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        fromDirX - the x-coordinate of the direction to rotate into the destination direction
        fromDirY - the y-coordinate of the direction to rotate into the destination direction
        fromDirZ - the z-coordinate of the direction to rotate into the destination direction
        toDirX - the x-coordinate of the direction to rotate to
        toDirY - the y-coordinate of the direction to rotate to
        toDirZ - the z-coordinate of the direction to rotate to
        Returns:
        this
        See Also:
        rotateTo(float, float, float, float, float, float, Quaternionf)
      • rotateTo

        public Quaternionf rotateTo​(Vector3fc fromDir,
                                    Vector3fc toDir,
                                    Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this that rotates the fromDir vector to point along toDir and store the result in dest.

        Because there can be multiple possible rotations, this method chooses the one with the shortest arc.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateTo in interface Quaternionfc
        Parameters:
        fromDir - the starting direction
        toDir - the destination direction
        dest - will hold the result
        Returns:
        dest
        See Also:
        Quaternionfc.rotateTo(float, float, float, float, float, float, Quaternionf)
      • rotateTo

        public Quaternionf rotateTo​(Vector3fc fromDir,
                                    Vector3fc toDir)
        Apply a rotation to this that rotates the fromDir vector to point along toDir.

        Because there can be multiple possible rotations, this method chooses the one with the shortest arc.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        fromDir - the starting direction
        toDir - the destination direction
        Returns:
        this
        See Also:
        rotateTo(float, float, float, float, float, float, Quaternionf)
      • rotateX

        public Quaternionf rotateX​(float angle)
        Apply a rotation to this quaternion rotating the given radians about the x axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the x axis
        Returns:
        this
      • rotateX

        public Quaternionf rotateX​(float angle,
                                   Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the x axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateX in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the x axis
        dest - will hold the result
        Returns:
        dest
      • rotateY

        public Quaternionf rotateY​(float angle)
        Apply a rotation to this quaternion rotating the given radians about the y axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the y axis
        Returns:
        this
      • rotateY

        public Quaternionf rotateY​(float angle,
                                   Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the y axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateY in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the y axis
        dest - will hold the result
        Returns:
        dest
      • rotateZ

        public Quaternionf rotateZ​(float angle)
        Apply a rotation to this quaternion rotating the given radians about the z axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the z axis
        Returns:
        this
      • rotateZ

        public Quaternionf rotateZ​(float angle,
                                   Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the z axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateZ in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the z axis
        dest - will hold the result
        Returns:
        dest
      • rotateLocalX

        public Quaternionf rotateLocalX​(float angle)
        Apply a rotation to this quaternion rotating the given radians about the local x axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be R * Q. So when transforming a vector v with the new quaternion by using R * Q * v, the rotation represented by this will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the local x axis
        Returns:
        this
      • rotateLocalX

        public Quaternionf rotateLocalX​(float angle,
                                        Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the local x axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be R * Q. So when transforming a vector v with the new quaternion by using R * Q * v, the rotation represented by this will be applied first!

        Specified by:
        rotateLocalX in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the local x axis
        dest - will hold the result
        Returns:
        dest
      • rotateLocalY

        public Quaternionf rotateLocalY​(float angle)
        Apply a rotation to this quaternion rotating the given radians about the local y axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be R * Q. So when transforming a vector v with the new quaternion by using R * Q * v, the rotation represented by this will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the local y axis
        Returns:
        this
      • rotateLocalY

        public Quaternionf rotateLocalY​(float angle,
                                        Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the local y axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be R * Q. So when transforming a vector v with the new quaternion by using R * Q * v, the rotation represented by this will be applied first!

        Specified by:
        rotateLocalY in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the local y axis
        dest - will hold the result
        Returns:
        dest
      • rotateLocalZ

        public Quaternionf rotateLocalZ​(float angle)
        Apply a rotation to this quaternion rotating the given radians about the local z axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be R * Q. So when transforming a vector v with the new quaternion by using R * Q * v, the rotation represented by this will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the local z axis
        Returns:
        this
      • rotateLocalZ

        public Quaternionf rotateLocalZ​(float angle,
                                        Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the local z axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be R * Q. So when transforming a vector v with the new quaternion by using R * Q * v, the rotation represented by this will be applied first!

        Specified by:
        rotateLocalZ in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the local z axis
        dest - will hold the result
        Returns:
        dest
      • rotateAxis

        public Quaternionf rotateAxis​(float angle,
                                      float axisX,
                                      float axisY,
                                      float axisZ,
                                      Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the specified axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateAxis in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the specified axis
        axisX - the x coordinate of the rotation axis
        axisY - the y coordinate of the rotation axis
        axisZ - the z coordinate of the rotation axis
        dest - will hold the result
        Returns:
        dest
      • rotateAxis

        public Quaternionf rotateAxis​(float angle,
                                      Vector3fc axis,
                                      Quaternionf dest)
        Description copied from interface: Quaternionfc
        Apply a rotation to this quaternion rotating the given radians about the specified axis and store the result in dest.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Specified by:
        rotateAxis in interface Quaternionfc
        Parameters:
        angle - the angle in radians to rotate about the specified axis
        axis - the rotation axis
        dest - will hold the result
        Returns:
        dest
        See Also:
        Quaternionfc.rotateAxis(float, float, float, float, Quaternionf)
      • rotateAxis

        public Quaternionf rotateAxis​(float angle,
                                      Vector3fc axis)
        Apply a rotation to this quaternion rotating the given radians about the specified axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the specified axis
        axis - the rotation axis
        Returns:
        this
        See Also:
        rotateAxis(float, float, float, float, Quaternionf)
      • rotateAxis

        public Quaternionf rotateAxis​(float angle,
                                      float axisX,
                                      float axisY,
                                      float axisZ)
        Apply a rotation to this quaternion rotating the given radians about the specified axis.

        If Q is this quaternion and R the quaternion representing the specified rotation, then the new quaternion will be Q * R. So when transforming a vector v with the new quaternion by using Q * R * v, the rotation added by this method will be applied first!

        Parameters:
        angle - the angle in radians to rotate about the specified axis
        axisX - the x coordinate of the rotation axis
        axisY - the y coordinate of the rotation axis
        axisZ - the z coordinate of the rotation axis
        Returns:
        this
        See Also:
        rotateAxis(float, float, float, float, Quaternionf)
      • toString

        public java.lang.String toString()
        Return a string representation of this quaternion.

        This method creates a new DecimalFormat on every invocation with the format string "0.000E0;-".

        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation
      • toString

        public java.lang.String toString​(java.text.NumberFormat formatter)
        Return a string representation of this quaternion by formatting the components with the given NumberFormat.
        Parameters:
        formatter - the NumberFormat used to format the quaternion components with
        Returns:
        the string representation
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • difference

        public Quaternionf difference​(Quaternionf other)
        Compute the difference between this and the other quaternion and store the result in this.

        The difference is the rotation that has to be applied to get from this rotation to other. If T is this, Q is other and D is the computed difference, then the following equation holds:

        T * D = Q

        It is defined as: D = T^-1 * Q, where T^-1 denotes the inverse of T.

        Parameters:
        other - the other quaternion
        Returns:
        this
      • difference

        public Quaternionf difference​(Quaternionfc other,
                                      Quaternionf dest)
        Description copied from interface: Quaternionfc
        Compute the difference between this and the other quaternion and store the result in dest.

        The difference is the rotation that has to be applied to get from this rotation to other. If T is this, Q is other and D is the computed difference, then the following equation holds:

        T * D = Q

        It is defined as: D = T^-1 * Q, where T^-1 denotes the inverse of T.

        Specified by:
        difference in interface Quaternionfc
        Parameters:
        other - the other quaternion
        dest - will hold the result
        Returns:
        dest
      • positiveX

        public Vector3f positiveX​(Vector3f dir)
        Description copied from interface: Quaternionfc
        Obtain the direction of +X before the rotation transformation represented by this quaternion is applied.

        This method is equivalent to the following code:

         Quaternionf inv = new Quaternionf(this).invert();
         inv.transform(dir.set(1, 0, 0));
         
        Specified by:
        positiveX in interface Quaternionfc
        Parameters:
        dir - will hold the direction of +X
        Returns:
        dir
      • normalizedPositiveX

        public Vector3f normalizedPositiveX​(Vector3f dir)
        Description copied from interface: Quaternionfc
        Obtain the direction of +X before the rotation transformation represented by this normalized quaternion is applied. The quaternion must be normalized for this method to work.

        This method is equivalent to the following code:

         Quaternionf inv = new Quaternionf(this).conjugate();
         inv.transform(dir.set(1, 0, 0));
         
        Specified by:
        normalizedPositiveX in interface Quaternionfc
        Parameters:
        dir - will hold the direction of +X
        Returns:
        dir
      • positiveY

        public Vector3f positiveY​(Vector3f dir)
        Description copied from interface: Quaternionfc
        Obtain the direction of +Y before the rotation transformation represented by this quaternion is applied.

        This method is equivalent to the following code:

         Quaternionf inv = new Quaternionf(this).invert();
         inv.transform(dir.set(0, 1, 0));
         
        Specified by:
        positiveY in interface Quaternionfc
        Parameters:
        dir - will hold the direction of +Y
        Returns:
        dir
      • normalizedPositiveY

        public Vector3f normalizedPositiveY​(Vector3f dir)
        Description copied from interface: Quaternionfc
        Obtain the direction of +Y before the rotation transformation represented by this normalized quaternion is applied. The quaternion must be normalized for this method to work.

        This method is equivalent to the following code:

         Quaternionf inv = new Quaternionf(this).conjugate();
         inv.transform(dir.set(0, 1, 0));
         
        Specified by:
        normalizedPositiveY in interface Quaternionfc
        Parameters:
        dir - will hold the direction of +Y
        Returns:
        dir
      • positiveZ

        public Vector3f positiveZ​(Vector3f dir)
        Description copied from interface: Quaternionfc
        Obtain the direction of +Z before the rotation transformation represented by this quaternion is applied.

        This method is equivalent to the following code:

         Quaternionf inv = new Quaternionf(this).invert();
         inv.transform(dir.set(0, 0, 1));
         
        Specified by:
        positiveZ in interface Quaternionfc
        Parameters:
        dir - will hold the direction of +Z
        Returns:
        dir
      • normalizedPositiveZ

        public Vector3f normalizedPositiveZ​(Vector3f dir)
        Description copied from interface: Quaternionfc
        Obtain the direction of +Z before the rotation transformation represented by this normalized quaternion is applied. The quaternion must be normalized for this method to work.

        This method is equivalent to the following code:

         Quaternionf inv = new Quaternionf(this).conjugate();
         inv.transform(dir.set(0, 0, 1));
         
        Specified by:
        normalizedPositiveZ in interface Quaternionfc
        Parameters:
        dir - will hold the direction of +Z
        Returns:
        dir
      • conjugateBy

        public Quaternionf conjugateBy​(Quaternionfc q)
        Conjugate this by the given quaternion q by computing q * this * q^-1.
        Parameters:
        q - the Quaternionfc to conjugate this by
        Returns:
        this
      • isFinite

        public boolean isFinite()
        Description copied from interface: Quaternionfc
        Determine whether all components are finite floating-point values, that is, they are not NaN and not infinity.
        Specified by:
        isFinite in interface Quaternionfc
        Returns:
        true if all components are finite floating-point values; false otherwise
      • equals

        public boolean equals​(Quaternionfc q,
                              float delta)
        Description copied from interface: Quaternionfc
        Compare the quaternion components of this quaternion with the given quaternion using the given delta and return whether all of them are equal within a maximum difference of delta.

        Please note that this method is not used by any data structure such as ArrayList HashSet or HashMap and their operations, such as ArrayList.contains(Object) or HashSet.remove(Object), since those data structures only use the Object.equals(Object) and Object.hashCode() methods.

        Specified by:
        equals in interface Quaternionfc
        Parameters:
        q - the other quaternion
        delta - the allowed maximum difference
        Returns:
        true whether all of the quaternion components are equal; false otherwise
      • equals

        public boolean equals​(float x,
                              float y,
                              float z,
                              float w)
        Specified by:
        equals in interface Quaternionfc
        Parameters:
        x - the x component to compare to
        y - the y component to compare to
        z - the z component to compare to
        w - the w component to compare to
        Returns:
        true if all the quaternion components are equal
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException