Interface Quaternion

  • All Superinterfaces:
    Cloneable, Serializable

    public interface Quaternion
    extends Cloneable, Serializable
    A 4 element unit quaternion represented by x, y, z, w coordinates. The quaternion is always normalized.

    Other Rotation Representations

    Other representations of an rotation are available from this class: axis-angle, and Euler angles.

    Axis Angles

    The axis–angle representation of a rotation parameterizes a rotation in a three-dimensional Euclidean space by two values: a unit vector, indicating the direction of an axis of rotation, and an angle describing the magnitude of the rotation about the axis. The rotation occurs in the sense prescribed by the (left/right)-hand rule. [Axis-Angle Representation]

    Euler Angles

    The term "Euler Angle" is used for any representation of 3 dimensional rotations where the rotation is decomposed into 3 separate angles.

    There is no single set of conventions and standards in this area, therefore the following conventions was choosen:

    • angle applied first: heading;
    • angle applied second: attitude;
    • angle applied last: bank

    Examples: NASA aircraft standard and telescope standard [NASA Aircraft Standard] [Telescope Standard]

    Version:
    17.0 2020-01-04 14:41:43
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathgeom
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Quaternion.AxisAngle
      A representation of axis-angle.
      static class  Quaternion.EulerAngles
      A representation of Euler Angles.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void conjugate()
      Sets the value of this quaternion to the conjugate of itself.
      void conjugate​(Quaternion q1)
      Sets the value of this quaternion to the conjugate of quaternion q1.
      boolean epsilonEquals​(Quaternion t1, double epsilon)
      Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false.
      double getAngle()
      Replies the rotation angle represented by this quaternion.
      Vector3D<?,​?> getAxis()
      Replies the rotation axis-angle represented by this quaternion.
      Quaternion.AxisAngle getAxisAngle()
      Replies the rotation axis represented by this quaternion.
      Quaternion.EulerAngles getEulerAngles()
      Replies the Euler's angles that corresponds to the quaternion.
      Quaternion.EulerAngles getEulerAngles​(CoordinateSystem3D system)
      Replies the Euler's angles that corresponds to the quaternion.
      double getW()
      Replies the W coordinate.
      double getX()
      Replies the X coordinate.
      double getY()
      Replies the Y coordinate.
      double getZ()
      Replies the Z coordinate.
      void interpolate​(Quaternion q1, double alpha)
      Performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion.
      void interpolate​(Quaternion q1, Quaternion q2, double alpha)
      Performs a great circle interpolation between quaternion q1 and quaternion q2 and places the result into this quaternion.
      void inverse()
      Sets the value of this quaternion to the quaternion inverse of itself.
      void inverse​(Quaternion q1)
      Sets the value of this quaternion to quaternion inverse of quaternion q1.
      void mul​(Quaternion q1)
      Sets the value of this quaternion to the quaternion product of itself and q1 (this = this * q1).
      void mul​(Quaternion q1, Quaternion q2)
      Sets the value of this quaternion to the quaternion product of quaternions q1 and q2 (this = q1 * q2).
      void mulInverse​(Quaternion q1)
      Multiplies this quaternion by the inverse of quaternion q1 and places the value into this quaternion.
      void mulInverse​(Quaternion q1, Quaternion q2)
      Multiplies quaternion q1 by the inverse of quaternion q2 and places the value into this quaternion.
      void normalize()
      Normalizes the value of this quaternion in place.
      void normalize​(Quaternion q1)
      Sets the value of this quaternion to the normalized value of quaternion q1.
      void set​(double x, double y, double z, double w)
      Set the quaternion coordinates.
      void set​(Quaternion quat)
      Set the quaternion coordinates.
      void setAxisAngle​(double x1, double y1, double z1, double angle)
      Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.
      void setAxisAngle​(Vector3D<?,​?> axis, double angle)
      Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.
      void setEulerAngles​(double attitude, double bank, double heading)
      Set the quaternion with the Euler angles.
      void setEulerAngles​(double attitude, double bank, double heading, CoordinateSystem3D system)
      Set the quaternion with the Euler angles.
      void setEulerAngles​(Quaternion.EulerAngles angles)
      Set the quaternion with the Euler angles.
      void setFromMatrix​(Matrix3d m1)
      Sets the value of this quaternion to the rotational component of the passed matrix.
      void setFromMatrix​(Matrix4d m1)
      Sets the value of this quaternion to the rotational component of the passed matrix.
      void setW​(double w)
      Set the W coordinate.
      void setX​(double x)
      Set the X coordinate.
      void setY​(double y)
      Set the Y coordinate.
      void setZ​(double z)
      Set the Z coordinate.
    • Method Detail

      • getX

        @Pure
        double getX()
        Replies the X coordinate.
        Returns:
        x
      • setX

        void setX​(double x)
        Set the X coordinate.
        Parameters:
        x - x coordinate.
      • getY

        @Pure
        double getY()
        Replies the Y coordinate.
        Returns:
        y
      • setY

        void setY​(double y)
        Set the Y coordinate.
        Parameters:
        y - y coordinate.
      • getZ

        @Pure
        double getZ()
        Replies the Z coordinate.
        Returns:
        z
      • setZ

        void setZ​(double z)
        Set the Z coordinate.
        Parameters:
        z - z coordinate.
      • getW

        @Pure
        double getW()
        Replies the W coordinate.
        Returns:
        w
      • setW

        void setW​(double w)
        Set the W coordinate.
        Parameters:
        w - w coordinate.
      • epsilonEquals

        @Pure
        boolean epsilonEquals​(Quaternion t1,
                              double epsilon)
        Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].
        Parameters:
        t1 - the tuple to be compared to this tuple
        epsilon - the threshold value
        Returns:
        true or false
      • conjugate

        void conjugate​(Quaternion q1)
        Sets the value of this quaternion to the conjugate of quaternion q1.
        Parameters:
        q1 - the source vector
      • conjugate

        void conjugate()
        Sets the value of this quaternion to the conjugate of itself.
      • mul

        void mul​(Quaternion q1,
                 Quaternion q2)
        Sets the value of this quaternion to the quaternion product of quaternions q1 and q2 (this = q1 * q2). Note that this is safe for aliasing (e.g. this can be q1 or q2).
        Parameters:
        q1 - the first quaternion
        q2 - the second quaternion
      • mul

        void mul​(Quaternion q1)
        Sets the value of this quaternion to the quaternion product of itself and q1 (this = this * q1).
        Parameters:
        q1 - the other quaternion
      • mulInverse

        void mulInverse​(Quaternion q1,
                        Quaternion q2)
        Multiplies quaternion q1 by the inverse of quaternion q2 and places the value into this quaternion. The value of both argument quaternions is preservered (this = q1 * q2^-1).
        Parameters:
        q1 - the first quaternion
        q2 - the second quaternion
      • mulInverse

        void mulInverse​(Quaternion q1)
        Multiplies this quaternion by the inverse of quaternion q1 and places the value into this quaternion. The value of the argument quaternion is preserved (this = this * q^-1).
        Parameters:
        q1 - the other quaternion
      • inverse

        void inverse​(Quaternion q1)
        Sets the value of this quaternion to quaternion inverse of quaternion q1.
        Parameters:
        q1 - the quaternion to be inverted
      • inverse

        void inverse()
        Sets the value of this quaternion to the quaternion inverse of itself.
      • normalize

        void normalize​(Quaternion q1)
        Sets the value of this quaternion to the normalized value of quaternion q1.
        Parameters:
        q1 - the quaternion to be normalized.
      • normalize

        void normalize()
        Normalizes the value of this quaternion in place.
      • setFromMatrix

        void setFromMatrix​(Matrix4d m1)
        Sets the value of this quaternion to the rotational component of the passed matrix.
        Parameters:
        m1 - the Matrix4f
      • setFromMatrix

        void setFromMatrix​(Matrix3d m1)
        Sets the value of this quaternion to the rotational component of the passed matrix.
        Parameters:
        m1 - the Matrix3f
      • set

        void set​(double x,
                 double y,
                 double z,
                 double w)
        Set the quaternion coordinates.
        Parameters:
        x - x coordinate.
        y - y coordinate.
        z - z coordinate.
        w - w coordinate.
      • set

        void set​(Quaternion quat)
        Set the quaternion coordinates.
        Parameters:
        quat - the quaternion to copy.
      • setAxisAngle

        void setAxisAngle​(Vector3D<?,​?> axis,
                          double angle)
        Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.
        Parameters:
        axis - is the axis of rotation.
        angle - is the rotation around the axis.
      • setAxisAngle

        void setAxisAngle​(double x1,
                          double y1,
                          double z1,
                          double angle)
        Sets the value of this quaternion to the equivalent rotation of the Axis-Angle arguments.
        Parameters:
        x1 - is the x coordinate of the rotation axis
        y1 - is the y coordinate of the rotation axis
        z1 - is the z coordinate of the rotation axis
        angle - is the rotation around the axis.
      • getAxis

        @Pure
        Vector3D<?,​?> getAxis()
        Replies the rotation axis-angle represented by this quaternion.
        Returns:
        the rotation axis-angle.
      • interpolate

        void interpolate​(Quaternion q1,
                         double alpha)
        Performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion.
        Parameters:
        q1 - the other quaternion
        alpha - the alpha interpolation parameter
      • interpolate

        void interpolate​(Quaternion q1,
                         Quaternion q2,
                         double alpha)
        Performs a great circle interpolation between quaternion q1 and quaternion q2 and places the result into this quaternion.
        Parameters:
        q1 - the first quaternion
        q2 - the second quaternion
        alpha - the alpha interpolation parameter
      • setEulerAngles

        void setEulerAngles​(double attitude,
                            double bank,
                            double heading,
                            CoordinateSystem3D system)
        Set the quaternion with the Euler angles.
        Parameters:
        attitude - is the rotation around left vector.
        bank - is the rotation around front vector.
        heading - is the rotation around top vector.
        system - the coordinate system to use for applying the Euler angles.
        See Also:
        Euler Angles, Euler to Quaternion