Package org.joml

Class Quaterniond

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, Quaterniondc

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

      Fields 
      Modifier and Type Field Description
      double w
      The real/scalar part of the quaternion.
      double x
      The first component of the vector part.
      double y
      The second component of the vector part.
      double z
      The third component of the vector part.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Quaterniond add​(double x, double y, double z, double w)
      Add the quaternion (x, y, z, w) to this quaternion.
      Quaterniond add​(double x, double y, double z, double w, Quaterniond dest)
      Add the quaternion (x, y, z, w) to this quaternion and store the result in dest.
      Quaterniond add​(Quaterniondc q2)
      Add q2 to this quaternion.
      Quaterniond add​(Quaterniondc q2, Quaterniond dest)
      Add q2 to this quaternion and store the result in dest.
      double angle()
      Return the angle in radians represented by this quaternion rotation.
      Quaterniond conjugate()
      Conjugate this quaternion.
      Quaterniond conjugate​(Quaterniond dest)
      Conjugate this quaternion and store the result in dest.
      Quaterniond difference​(Quaterniondc other)
      Compute the difference between this and the other quaternion and store the result in this.
      Quaterniond difference​(Quaterniondc other, Quaterniond dest)
      Compute the difference between this and the other quaternion and store the result in dest.
      Quaterniond div​(Quaterniondc b)
      Divide this quaternion by b.
      Quaterniond div​(Quaterniondc b, Quaterniond dest)
      Divide this quaternion by b and store the result in dest.
      double dot​(Quaterniondc otherQuat)
      Return the dot product of this Quaterniond and otherQuat.
      boolean equals​(java.lang.Object obj)  
      Quaterniond fromAxisAngleDeg​(double axisX, double axisY, double axisZ, double angle)
      Set this quaternion to be a representation of the supplied axis and angle (in degrees).
      Quaterniond fromAxisAngleDeg​(Vector3dc axis, double angle)
      Set this quaternion to be a representation of the supplied axis and angle (in degrees).
      Quaterniond fromAxisAngleRad​(double axisX, double axisY, double axisZ, double angle)
      Set this quaternion to be a representation of the supplied axis and angle (in radians).
      Quaterniond fromAxisAngleRad​(Vector3dc axis, double angle)
      Set this quaternion to be a representation of the supplied axis and angle (in radians).
      Matrix3d get​(Matrix3d dest)
      Set the given destination matrix to the rotation represented by this.
      Matrix3f get​(Matrix3f dest)
      Set the given destination matrix to the rotation represented by this.
      Matrix4d get​(Matrix4d dest)
      Set the given destination matrix to the rotation represented by this.
      Matrix4f get​(Matrix4f dest)
      Set the given destination matrix to the rotation represented by this.
      Quaterniond get​(Quaterniond dest)
      Set the given Quaterniond to the values of this.
      Vector3d getEulerAnglesXYZ​(Vector3d eulerAngles)
      Get the euler angles in radians in rotation sequence XYZ of this quaternion and store them in the provided parameter eulerAngles.
      int hashCode()  
      Quaterniond identity()
      Set this quaternion to the identity.
      Quaterniond integrate​(double dt, double vx, double vy, double 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.
      Quaterniond integrate​(double dt, double vx, double vy, double vz, Quaterniond dest)
      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.
      Quaterniond invert()
      Invert this quaternion and normalize it.
      Quaterniond invert​(Quaterniond dest)
      Invert this quaternion and store the normalized result in dest.
      double lengthSquared()
      Return the square of the length of this quaternion.
      Quaterniond lookAlong​(double dirX, double dirY, double dirZ, double upX, double upY, double upZ)
      Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
      Quaterniond lookAlong​(double dirX, double dirY, double dirZ, double upX, double upY, double upZ, Quaterniond dest)
      Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result in dest.
      Quaterniond lookAlong​(Vector3dc dir, Vector3dc up)
      Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
      Quaterniond lookAlong​(Vector3dc dir, Vector3dc up, Quaterniond dest)
      Apply a rotation to this quaternion that maps the given direction to the positive Z axis, and store the result in dest.
      Quaterniond mul​(double qx, double qy, double qz, double qw)
      Multiply this quaternion by the quaternion represented via (qx, qy, qz, qw).
      Quaterniond mul​(double qx, double qy, double qz, double qw, Quaterniond dest)
      Multiply this quaternion by the quaternion represented via (qx, qy, qz, qw) and store the result in dest.
      Quaterniond mul​(Quaterniondc q)
      Multiply this quaternion by q.
      Quaterniond mul​(Quaterniondc q, Quaterniond dest)
      Multiply this quaternion by q and store the result in dest.
      static Quaterniondc nlerp​(Quaterniond[] qs, double[] weights, Quaterniond 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.
      Quaterniond nlerp​(Quaterniondc q, double factor)
      Compute a linear (non-spherical) interpolation of this and the given quaternion q and store the result in this.
      Quaterniond nlerp​(Quaterniondc q, double factor, Quaterniond dest)
      Compute a linear (non-spherical) interpolation of this and the given quaternion q and store the result in dest.
      static Quaterniond nlerpIterative​(Quaterniondc[] qs, double[] weights, double dotThreshold, Quaterniond 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.
      Quaterniond nlerpIterative​(Quaterniondc q, double alpha, double dotThreshold)
      Compute linear (non-spherical) interpolations of this and the given quaternion q iteratively and store the result in this.
      Quaterniond nlerpIterative​(Quaterniondc q, double alpha, double dotThreshold, Quaterniond dest)
      Compute linear (non-spherical) interpolations of this and the given quaternion q iteratively and store the result in dest.
      Quaterniond normalize()
      Normalize this quaternion.
      Quaterniond normalize​(Quaterniond dest)
      Normalize this quaternion and store the result in dest.
      Vector3d normalizedPositiveX​(Vector3d dir)
      Obtain the direction of +X before the rotation transformation represented by this normalized quaternion is applied.
      Vector3d normalizedPositiveY​(Vector3d dir)
      Obtain the direction of +Y before the rotation transformation represented by this normalized quaternion is applied.
      Vector3d normalizedPositiveZ​(Vector3d dir)
      Obtain the direction of +Z before the rotation transformation represented by this normalized quaternion is applied.
      Vector3d positiveX​(Vector3d dir)
      Obtain the direction of +X before the rotation transformation represented by this quaternion is applied.
      Vector3d positiveY​(Vector3d dir)
      Obtain the direction of +Y before the rotation transformation represented by this quaternion is applied.
      Vector3d positiveZ​(Vector3d dir)
      Obtain the direction of +Z before the rotation transformation represented by this quaternion is applied.
      Quaterniond premul​(double qx, double qy, double qz, double qw)
      Pre-multiply this quaternion by the quaternion represented via (qx, qy, qz, qw).
      Quaterniond premul​(double qx, double qy, double qz, double qw, Quaterniond dest)
      Pre-multiply this quaternion by the quaternion represented via (qx, qy, qz, qw) and store the result in dest.
      Quaterniond premul​(Quaterniondc q)
      Pre-multiply this quaternion by q.
      Quaterniond premul​(Quaterniondc q, Quaterniond dest)
      Pre-multiply this quaternion by q and store the result in dest.
      void readExternal​(java.io.ObjectInput in)  
      Quaterniond rotateAxis​(double angle, double axisX, double axisY, double axisZ)
      Apply a rotation to this quaternion rotating the given radians about the specified axis.
      Quaterniond rotateAxis​(double angle, double axisX, double axisY, double axisZ, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the specified axis and store the result in dest.
      Quaterniond rotateAxis​(double angle, Vector3dc axis)
      Apply a rotation to this quaternion rotating the given radians about the specified axis.
      Quaterniond rotateAxis​(double angle, Vector3dc axis, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the specified axis and store the result in dest.
      Quaterniond rotateLocalX​(double angle)
      Apply a rotation to this quaternion rotating the given radians about the local x axis.
      Quaterniond rotateLocalX​(double angle, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the local x axis and store the result in dest.
      Quaterniond rotateLocalY​(double angle)
      Apply a rotation to this quaternion rotating the given radians about the local y axis.
      Quaterniond rotateLocalY​(double angle, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the local y axis and store the result in dest.
      Quaterniond rotateLocalZ​(double angle)
      Apply a rotation to this quaternion rotating the given radians about the local z axis.
      Quaterniond rotateLocalZ​(double angle, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the local z axis and store the result in dest.
      Quaterniond rotateTo​(double fromDirX, double fromDirY, double fromDirZ, double toDirX, double toDirY, double toDirZ)
      Apply a rotation to this that rotates the fromDir vector to point along toDir.
      Quaterniond rotateTo​(double fromDirX, double fromDirY, double fromDirZ, double toDirX, double toDirY, double toDirZ, Quaterniond dest)
      Apply a rotation to this that rotates the fromDir vector to point along toDir and store the result in dest.
      Quaterniond rotateTo​(Vector3dc fromDir, Vector3dc toDir)
      Apply a rotation to this that rotates the fromDir vector to point along toDir.
      Quaterniond rotateTo​(Vector3dc fromDir, Vector3dc toDir, Quaterniond dest)
      Apply a rotation to this that rotates the fromDir vector to point along toDir and store the result in dest.
      Quaterniond rotateX​(double angle)
      Apply a rotation to this quaternion rotating the given radians about the x axis.
      Quaterniond rotateX​(double angle, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the x axis and store the result in dest.
      Quaterniond rotateXYZ​(double angleX, double angleY, double 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.
      Quaterniond rotateXYZ​(double angleX, double angleY, double angleZ, Quaterniond dest)
      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.
      Quaterniond rotateY​(double angle)
      Apply a rotation to this quaternion rotating the given radians about the y axis.
      Quaterniond rotateY​(double angle, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the y axis and store the result in dest.
      Quaterniond rotateYXZ​(double angleZ, double angleY, double 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 YXZ.
      Quaterniond rotateYXZ​(double angleY, double angleX, double angleZ, Quaterniond dest)
      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.
      Quaterniond rotateZ​(double angle)
      Apply a rotation to this quaternion rotating the given radians about the z axis.
      Quaterniond rotateZ​(double angle, Quaterniond dest)
      Apply a rotation to this quaternion rotating the given radians about the z axis and store the result in dest.
      Quaterniond rotateZYX​(double angleZ, double angleY, double 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.
      Quaterniond rotateZYX​(double angleZ, double angleY, double angleX, Quaterniond dest)
      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.
      Quaterniond rotationAxis​(double angle, double axisX, double axisY, double axisZ)
      Set this quaternion to a rotation of the given angle in radians about the supplied axis.
      Quaterniond rotationAxis​(AxisAngle4f axisAngle)
      Set this Quaterniond to a rotation of the given angle in radians about the supplied axis, all of which are specified via the AxisAngle4f.
      Quaterniond rotationTo​(double fromDirX, double fromDirY, double fromDirZ, double toDirX, double toDirY, double toDirZ)
      Set this quaternion to a rotation that rotates the fromDir vector to point along toDir.
      Quaterniond rotationTo​(Vector3dc fromDir, Vector3dc toDir)
      Set this quaternion to a rotation that rotates the fromDir vector to point along toDir.
      Quaterniond rotationX​(double angle)
      Set this quaternion to represent a rotation of the given radians about the x axis.
      Quaterniond rotationXYZ​(double angleX, double angleY, double angleZ)
      Set this quaternion from the supplied euler angles (in radians) with rotation order XYZ.
      Quaterniond rotationY​(double angle)
      Set this quaternion to represent a rotation of the given radians about the y axis.
      Quaterniond rotationYXZ​(double angleY, double angleX, double angleZ)
      Set this quaternion from the supplied euler angles (in radians) with rotation order YXZ.
      Quaterniond rotationZ​(double angle)
      Set this quaternion to represent a rotation of the given radians about the z axis.
      Quaterniond rotationZYX​(double angleZ, double angleY, double angleX)
      Set this quaternion from the supplied euler angles (in radians) with rotation order ZYX.
      Quaterniond scale​(double factor)
      Apply scaling to this quaternion, which results in any vector transformed by this quaternion to change its length by the given factor.
      Quaterniond scale​(double factor, Quaterniond dest)
      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.
      Quaterniond scaling​(double factor)
      Set this quaternion to represent scaling, which results in a transformed vector to change its length by the given factor.
      Quaterniond set​(double x, double y, double z, double w)
      Set this quaternion to the new values.
      Quaterniond set​(AxisAngle4d axisAngle)
      Set this Quaterniond to be equivalent to the given AxisAngle4d.
      Quaterniond set​(AxisAngle4f axisAngle)
      Set this Quaterniond to be equivalent to the given AxisAngle4f.
      Quaterniond set​(Quaterniondc q)
      Set this quaternion to be a copy of q.
      Quaterniond set​(Quaternionfc q)
      Set this quaternion to be a copy of q.
      Quaterniond setAngleAxis​(double angle, double x, double y, double z)
      Set this quaternion to a rotation equivalent to the supplied axis and angle (in radians).
      Quaterniond setAngleAxis​(double angle, Vector3dc axis)
      Set this quaternion to be a representation of the supplied axis and angle (in radians).
      Quaterniond setFromNormalized​(Matrix3dc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromNormalized​(Matrix3fc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromNormalized​(Matrix4dc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromNormalized​(Matrix4fc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromNormalized​(Matrix4x3dc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromNormalized​(Matrix4x3fc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromUnnormalized​(Matrix3dc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromUnnormalized​(Matrix3fc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromUnnormalized​(Matrix4dc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromUnnormalized​(Matrix4fc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromUnnormalized​(Matrix4x3dc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      Quaterniond setFromUnnormalized​(Matrix4x3fc mat)
      Set this quaternion to be a representation of the rotational component of the given matrix.
      static Quaterniondc slerp​(Quaterniond[] qs, double[] weights, Quaterniond 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.
      Quaterniond slerp​(Quaterniondc target, double alpha)
      Interpolate between this unit quaternion and the specified target unit quaternion using spherical linear interpolation using the specified interpolation factor alpha.
      Quaterniond slerp​(Quaterniondc target, double alpha, Quaterniond dest)
      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.
      java.lang.String toString()
      Return a string representation of this quaternion.
      java.lang.String toString​(java.text.NumberFormat formatter)
      Return a string representation of this quaternion by formatting the components with the given NumberFormat.
      Vector3d transform​(double x, double y, double z, Vector3d dest)
      Transform the given vector (x, y, z) by this quaternion and store the result in dest.
      Vector4d transform​(double x, double y, double z, Vector4d dest)
      Transform the given vector (x, y, z) by this quaternion and store the result in dest.
      Vector3d transform​(Vector3d vec)
      Transform the given vector by this quaternion.
      Vector3d transform​(Vector3dc vec, Vector3d dest)
      Transform the given vector by this quaternion and store the result in dest.
      Vector4d transform​(Vector4d vec)
      Transform the given vector by this quaternion.
      Vector4d transform​(Vector4dc vec, Vector4d dest)
      Transform the given vector by this quaternion and store the result in dest.
      Vector3d transformPositiveX​(Vector3d dest)
      Transform the vector (1, 0, 0) by this quaternion.
      Vector4d transformPositiveX​(Vector4d dest)
      Transform the vector (1, 0, 0) by this quaternion.
      Vector3d transformPositiveY​(Vector3d dest)
      Transform the vector (0, 1, 0) by this quaternion.
      Vector4d transformPositiveY​(Vector4d dest)
      Transform the vector (0, 1, 0) by this quaternion.
      Vector3d transformPositiveZ​(Vector3d dest)
      Transform the vector (0, 0, 1) by this quaternion.
      Vector4d transformPositiveZ​(Vector4d dest)
      Transform the vector (0, 0, 1) by this quaternion.
      Vector3d transformUnitPositiveX​(Vector3d dest)
      Transform the vector (1, 0, 0) by this unit quaternion.
      Vector4d transformUnitPositiveX​(Vector4d dest)
      Transform the vector (1, 0, 0) by this unit quaternion.
      Vector3d transformUnitPositiveY​(Vector3d dest)
      Transform the vector (0, 1, 0) by this unit quaternion.
      Vector4d transformUnitPositiveY​(Vector4d dest)
      Transform the vector (0, 1, 0) by this unit quaternion.
      Vector3d transformUnitPositiveZ​(Vector3d dest)
      Transform the vector (0, 0, 1) by this unit quaternion.
      Vector4d transformUnitPositiveZ​(Vector4d dest)
      Transform the vector (0, 0, 1) by this unit quaternion.
      double w()  
      void writeExternal​(java.io.ObjectOutput out)  
      double x()  
      double y()  
      double z()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

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

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

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

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

      • Quaterniond

        public Quaterniond()
        Create a new Quaterniond 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.
      • Quaterniond

        public Quaterniond​(double x,
                           double y,
                           double z,
                           double w)
        Create a new Quaterniond 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
      • Quaterniond

        public Quaterniond​(Quaterniondc source)
        Create a new Quaterniond and initialize its components to the same values as the given Quaterniond.
        Parameters:
        source - the Quaterniond to take the component values from
      • Quaterniond

        public Quaterniond​(AxisAngle4f axisAngle)
        Create a new Quaterniond and initialize it to represent the same rotation as the given AxisAngle4f.
        Parameters:
        axisAngle - the axis-angle to initialize this quaternion with
      • Quaterniond

        public Quaterniond​(AxisAngle4d axisAngle)
        Create a new Quaterniond and initialize it to represent the same rotation as the given AxisAngle4d.
        Parameters:
        axisAngle - the axis-angle to initialize this quaternion with
    • Method Detail

      • x

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

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

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

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

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

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

        public Quaterniond add​(double x,
                               double y,
                               double z,
                               double 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 Quaterniond add​(double x,
                               double y,
                               double z,
                               double w,
                               Quaterniond dest)
        Description copied from interface: Quaterniondc
        Add the quaternion (x, y, z, w) to this quaternion and store the result in dest.
        Specified by:
        add in interface Quaterniondc
        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 Quaterniond add​(Quaterniondc q2)
        Add q2 to this quaternion.
        Parameters:
        q2 - the quaternion to add to this
        Returns:
        this
      • add

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

        public double dot​(Quaterniondc otherQuat)
        Description copied from interface: Quaterniondc
        Return the dot product of this Quaterniond and otherQuat.
        Specified by:
        dot in interface Quaterniondc
        Parameters:
        otherQuat - the other quaternion
        Returns:
        the dot product
      • angle

        public double angle()
        Description copied from interface: Quaterniondc
        Return the angle in radians represented by this quaternion rotation.
        Specified by:
        angle in interface Quaterniondc
        Returns:
        the angle in radians
      • set

        public Quaterniond set​(double x,
                               double y,
                               double z,
                               double w)
        Set this quaternion to the new 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 Quaterniond 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
      • setAngleAxis

        public Quaterniond setAngleAxis​(double angle,
                                        Vector3dc axis)
        Set this quaternion to be a representation of the supplied axis and angle (in radians).
        Parameters:
        angle - the angle in radians
        axis - the rotation axis
        Returns:
        this
      • setFromUnnormalized

        public Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond 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 Quaterniond fromAxisAngleRad​(Vector3dc axis,
                                            double 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 Quaterniond fromAxisAngleRad​(double axisX,
                                            double axisY,
                                            double axisZ,
                                            double 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 Quaterniond fromAxisAngleDeg​(Vector3dc axis,
                                            double 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 Quaterniond fromAxisAngleDeg​(double axisX,
                                            double axisY,
                                            double axisZ,
                                            double 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 Quaterniond mul​(Quaterniondc 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 Quaterniond mul​(Quaterniondc q,
                               Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        q - the quaternion to multiply this by
        dest - will hold the result
        Returns:
        dest
      • mul

        public Quaterniond mul​(double qx,
                               double qy,
                               double qz,
                               double 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 Quaterniond mul​(double qx,
                               double qy,
                               double qz,
                               double qw,
                               Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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
      • premul

        public Quaterniond premul​(Quaterniondc 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 Quaterniond premul​(Quaterniondc q,
                                  Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        q - the quaternion to pre-multiply this by
        dest - will hold the result
        Returns:
        dest
      • premul

        public Quaterniond premul​(double qx,
                                  double qy,
                                  double qz,
                                  double 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 Quaterniond premul​(double qx,
                                  double qy,
                                  double qz,
                                  double qw,
                                  Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Vector3d transform​(Vector3d vec)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transformPositiveX

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

        public Vector4d transformPositiveX​(Vector4d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveX

        public Vector4d transformUnitPositiveX​(Vector4d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveY

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

        public Vector4d transformPositiveY​(Vector4d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveY

        public Vector4d transformUnitPositiveY​(Vector4d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformPositiveZ

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

        public Vector4d transformPositiveZ​(Vector4d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transformUnitPositiveZ

        public Vector4d transformUnitPositiveZ​(Vector4d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        dest - will hold the result
        Returns:
        dest
      • transform

        public Vector4d transform​(Vector4d vec)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        vec - the vector to transform
        Returns:
        vec
      • transform

        public Vector3d transform​(Vector3dc vec,
                                  Vector3d dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        vec - 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: Quaterniondc
        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 Quaterniondc
        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: Quaterniondc
        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 Quaterniondc
        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: Quaterniondc
        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 Quaterniondc
        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 Quaterniond div​(Quaterniondc b,
                               Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        b - the Quaterniondc to divide this by
        dest - will hold the result
        Returns:
        dest
      • div

        public Quaterniond div​(Quaterniondc 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 Quaterniondc to divide this by
        Returns:
        this
      • conjugate

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

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

        public Quaterniond identity()
        Set this quaternion to the identity.
        Returns:
        this
      • lengthSquared

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

        public Quaterniond rotationXYZ​(double angleX,
                                       double angleY,
                                       double 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 Quaterniond rotationZYX​(double angleZ,
                                       double angleY,
                                       double 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 Quaterniond rotationYXZ​(double angleY,
                                       double angleX,
                                       double 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 Quaterniond slerp​(Quaterniondc target,
                                 double 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 between this and target is below 1E-6.

        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 Quaterniond slerp​(Quaterniondc target,
                                 double alpha,
                                 Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 between this and target is below 1E-6.

        Reference: http://fabiensanglard.net

        Specified by:
        slerp in interface Quaterniondc
        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 Quaterniondc slerp​(Quaterniond[] qs,
                                         double[] weights,
                                         Quaterniond 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(Quaterniondc, double) 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 Quaterniond scale​(double 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 Quaterniond scale​(double factor,
                                 Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        factor - the scaling factor
        dest - will hold the result
        Returns:
        dest
      • scaling

        public Quaterniond scaling​(double 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 Quaterniond integrate​(double dt,
                                     double vx,
                                     double vy,
                                     double 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 Quaterniond integrate​(double dt,
                                     double vx,
                                     double vy,
                                     double vz,
                                     Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Quaterniond nlerp​(Quaterniondc q,
                                 double 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 Quaterniond nlerp​(Quaterniondc q,
                                 double factor,
                                 Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Quaterniondc nlerp​(Quaterniond[] qs,
                                         double[] weights,
                                         Quaterniond 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(Quaterniondc, double) 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 Quaterniond nlerpIterative​(Quaterniondc q,
                                          double alpha,
                                          double dotThreshold,
                                          Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Quaterniond nlerpIterative​(Quaterniondc q,
                                          double alpha,
                                          double 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 Quaterniond nlerpIterative​(Quaterniondc[] qs,
                                                 double[] weights,
                                                 double dotThreshold,
                                                 Quaterniond 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(Quaterniondc, double, double) 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(Quaterniondc, double, double) performs another iteration of a small-step linear interpolation
        dest - will hold the result
        Returns:
        dest
      • lookAlong

        public Quaterniond lookAlong​(Vector3dc dir,
                                     Vector3dc 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(double, double, double, double, double, double, Quaterniond)
      • lookAlong

        public Quaterniond lookAlong​(Vector3dc dir,
                                     Vector3dc up,
                                     Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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:
        Quaterniondc.lookAlong(double, double, double, double, double, double, Quaterniond)
      • lookAlong

        public Quaterniond lookAlong​(double dirX,
                                     double dirY,
                                     double dirZ,
                                     double upX,
                                     double upY,
                                     double 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(double, double, double, double, double, double, Quaterniond)
      • lookAlong

        public Quaterniond lookAlong​(double dirX,
                                     double dirY,
                                     double dirZ,
                                     double upX,
                                     double upY,
                                     double upZ,
                                     Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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
      • 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 Quaterniond difference​(Quaterniondc 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 Quaterniond difference​(Quaterniondc other,
                                      Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        other - the other quaternion
        dest - will hold the result
        Returns:
        dest
      • rotationTo

        public Quaterniond rotationTo​(double fromDirX,
                                      double fromDirY,
                                      double fromDirZ,
                                      double toDirX,
                                      double toDirY,
                                      double 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 Quaterniond rotationTo​(Vector3dc fromDir,
                                      Vector3dc 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(double, double, double, double, double, double)
      • rotateTo

        public Quaterniond rotateTo​(double fromDirX,
                                    double fromDirY,
                                    double fromDirZ,
                                    double toDirX,
                                    double toDirY,
                                    double toDirZ,
                                    Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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
      • rotationAxis

        public Quaterniond rotationAxis​(double angle,
                                        double axisX,
                                        double axisY,
                                        double 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
      • rotationX

        public Quaterniond rotationX​(double 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 Quaterniond rotationY​(double 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 Quaterniond rotationZ​(double 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
      • rotateTo

        public Quaterniond rotateTo​(double fromDirX,
                                    double fromDirY,
                                    double fromDirZ,
                                    double toDirX,
                                    double toDirY,
                                    double 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(double, double, double, double, double, double, Quaterniond)
      • rotateTo

        public Quaterniond rotateTo​(Vector3dc fromDir,
                                    Vector3dc toDir,
                                    Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        fromDir - the starting direction
        toDir - the destination direction
        dest - will hold the result
        Returns:
        dest
        See Also:
        Quaterniondc.rotateTo(double, double, double, double, double, double, Quaterniond)
      • rotateTo

        public Quaterniond rotateTo​(Vector3dc fromDir,
                                    Vector3dc 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(double, double, double, double, double, double, Quaterniond)
      • rotateX

        public Quaterniond rotateX​(double 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 Quaterniond rotateX​(double angle,
                                   Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        angle - the angle in radians to rotate about the x axis
        dest - will hold the result
        Returns:
        dest
      • rotateY

        public Quaterniond rotateY​(double 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 Quaterniond rotateY​(double angle,
                                   Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        angle - the angle in radians to rotate about the y axis
        dest - will hold the result
        Returns:
        dest
      • rotateZ

        public Quaterniond rotateZ​(double 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 Quaterniond rotateZ​(double angle,
                                   Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        angle - the angle in radians to rotate about the z axis
        dest - will hold the result
        Returns:
        dest
      • rotateLocalX

        public Quaterniond rotateLocalX​(double 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 Quaterniond rotateLocalX​(double angle,
                                        Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        angle - the angle in radians to rotate about the local x axis
        dest - will hold the result
        Returns:
        dest
      • rotateLocalY

        public Quaterniond rotateLocalY​(double 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 Quaterniond rotateLocalY​(double angle,
                                        Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        angle - the angle in radians to rotate about the local y axis
        dest - will hold the result
        Returns:
        dest
      • rotateLocalZ

        public Quaterniond rotateLocalZ​(double 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 Quaterniond rotateLocalZ​(double angle,
                                        Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        Parameters:
        angle - the angle in radians to rotate about the local z axis
        dest - will hold the result
        Returns:
        dest
      • rotateXYZ

        public Quaterniond rotateXYZ​(double angleX,
                                     double angleY,
                                     double 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 Quaterniond rotateXYZ​(double angleX,
                                     double angleY,
                                     double angleZ,
                                     Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Quaterniond rotateZYX​(double angleZ,
                                     double angleY,
                                     double 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 Quaterniond rotateZYX​(double angleZ,
                                     double angleY,
                                     double angleX,
                                     Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Quaterniond rotateYXZ​(double angleZ,
                                     double angleY,
                                     double 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 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 Quaterniond rotateYXZ​(double angleY,
                                     double angleX,
                                     double angleZ,
                                     Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Vector3d getEulerAnglesXYZ​(Vector3d eulerAngles)
        Description copied from interface: Quaterniondc
        Get the euler angles in radians in rotation sequence XYZ of this quaternion and store them in the provided parameter eulerAngles.
        Specified by:
        getEulerAnglesXYZ in interface Quaterniondc
        Parameters:
        eulerAngles - will hold the euler angles in radians
        Returns:
        the passed in vector
      • rotateAxis

        public Quaterniond rotateAxis​(double angle,
                                      double axisX,
                                      double axisY,
                                      double axisZ,
                                      Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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 Quaterniond rotateAxis​(double angle,
                                      Vector3dc axis,
                                      Quaterniond dest)
        Description copied from interface: Quaterniondc
        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 Quaterniondc
        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:
        Quaterniondc.rotateAxis(double, double, double, double, Quaterniond)
      • rotateAxis

        public Quaterniond rotateAxis​(double angle,
                                      Vector3dc 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(double, double, double, double, Quaterniond)
      • rotateAxis

        public Quaterniond rotateAxis​(double angle,
                                      double axisX,
                                      double axisY,
                                      double 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(double, double, double, double, Quaterniond)
      • positiveX

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

        This method is equivalent to the following code:

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

        public Vector3d normalizedPositiveX​(Vector3d dir)
        Description copied from interface: Quaterniondc
        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:

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

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

        This method is equivalent to the following code:

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

        public Vector3d normalizedPositiveY​(Vector3d dir)
        Description copied from interface: Quaterniondc
        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:

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

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

        This method is equivalent to the following code:

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

        public Vector3d normalizedPositiveZ​(Vector3d dir)
        Description copied from interface: Quaterniondc
        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:

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