Class EulerAngles

  • All Implemented Interfaces:
    Rotation<EulerAngles>, java.io.Serializable, javolution.lang.Immutable, javolution.lang.Realtime, javolution.lang.ValueType, javolution.xml.XMLSerializable

    public final class EulerAngles
    extends AbstractRotation<EulerAngles>
    implements javolution.xml.XMLSerializable
    This class represents the three Euler angles; theta1, theta2, theta3. Euler angles may be used to represents a relative attitude (attitude transformation or rotation) between two different reference frames; B wrt A or BA. It can be used to transform coordinates in reference frame A to reference frame B (A2B).

    Reference: Shoemake, Ken (1994), "Euler angle conversion", in Paul Heckbert, Graphics Gems IV, San Diego: Academic Press Professional, pp. 222-229, ISBN 978-0-12-336155-4.

    Modified by: Joseph A. Huwaldt

    Version:
    November 4, 2015
    Author:
    Joseph A. Huwaldt, Date: February 4, 2009
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  EulerAngles.Axis
      Enumeration of the axes that a rotation may be made around.
      static class  EulerAngles.Frame
      Enumeration of the frame from which the axes are taken.
      static class  EulerAngles.Order
      Enumeration of all the combinations of the Euler angle orders for both static ("s") and rotating ("r") axes.
      static class  EulerAngles.Parity
      Enumeration of the parity of the axis permutation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean NO
      Indicates that the initial axis is NOT repeated as the last axis.
      static EulerAngles.Order YAW_PITCH_ROLL
      The Euler order typically used in aerospace applications.
      static boolean YES
      Indicates repetition of initial axis as the last.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EulerAngles copy()
      Returns a copy of this set of Euler angles allocated by the calling thread (possibly on the stack).
      EulerAngles divide​(double divisor)
      Returns this set of Euler angles with each angle divided by the specified divisor.
      boolean equals​(java.lang.Object that)
      Compares this EulerAngles against the specified object for strict equality (same rotation type and same values).
      Parameter<javax.measure.quantity.Angle> get​(int i)
      Returns the value of an element from this set of Euler angles (0=1st axis, 1=2nd axis, 2=3rd axis).
      EulerAngles.Order getEulerOrder()
      Returns the Euler order for this set of Euler angles.
      javax.measure.unit.Unit<javax.measure.quantity.Angle> getUnit()
      Returns the unit in which the values in this set of Euler angles are stated in.
      double getValue​(int i)
      Returns the value of a floating point number from this set of Euler angles (0=1st axis, 1=2nd axis, 2=3rd axis).
      int hashCode()
      Returns the hash code for this rotation.
      static void main​(java.lang.String[] args)
      Tests the methods in this class.
      EulerAngles minus​(EulerAngles that)
      Returns the difference between this set of Euler angles and the one specified.
      EulerAngles minus​(Parameter<javax.measure.quantity.Angle> that)
      Subtracts the supplied angle from each element of this set of Euler angles and returns the result.
      EulerAngles minus​(Vector<Parameter<javax.measure.quantity.Angle>> that)
      Returns the difference between this set of Euler angles and the one specified.
      EulerAngles opposite()
      Returns the negation of this set of Euler angles (each angle is negated).
      EulerAngles plus​(EulerAngles that)
      Returns the sum of this set of Euler angles with the one specified.
      EulerAngles plus​(Parameter<javax.measure.quantity.Angle> that)
      Returns the sum of this set of Euler angles with the angle specified.
      EulerAngles plus​(Vector<Parameter<javax.measure.quantity.Angle>> that)
      Returns the sum of this set of Euler angles with the one specified.
      EulerAngles times​(double k)
      Returns the product of this set of Euler angles with the specified coefficient.
      EulerAngles times​(Rotation<?> that)
      Returns the product of this set of Euler angles and the specified rotation transform.
      EulerAngles to​(javax.measure.unit.Unit<javax.measure.quantity.Angle> unit)
      Returns the equivalent to this set of Euler angles but stated in the specified angle unit.
      DCMatrix toDCM()
      Returns a direction cosine transformation matrix from this set of Euler angles.
      Float64Vector toFloat64Vector()
      Returns the values stored in this set of Euler angles, in the current units, as a Float64Vector with the values ordered (1st axis angle, 2nd axis angle, 3rd axis angle).
      Quaternion toQuaternion()
      Returns a quaternion from this set of Euler angles.
      javolution.text.Text toText()
      Returns the text representation of this set of Euler angles.
      <Q extends javax.measure.quantity.Quantity>
      Vector3D<Q>
      transform​(Coordinate3D<Q> v)
      Transforms a 3D vector from frame A to B using this set of Euler angles.
      EulerAngles transpose()
      Returns the spatial inverse of this transformation: AB rather than BA.
      static EulerAngles valueOf​(Parameter<javax.measure.quantity.Angle> theta1, Parameter<javax.measure.quantity.Angle> theta2, Parameter<javax.measure.quantity.Angle> theta3, EulerAngles.Order eulerOrder)
      Returns an EulerAngles instance holding the specified Parameter<Angle> values for the rotation angle elements and the specified Euler order information.
      static EulerAngles valueOf​(Rotation<?> transform, EulerAngles.Order order)
      Returns an EulerAngles object constructed from the specified rotation transformation.
      static EulerAngles valueOf​(Vector3D<javax.measure.quantity.Angle> theta, EulerAngles.Axis initialAxis, EulerAngles.Parity parity, boolean repeat1st, EulerAngles.Frame frame)
      Returns an EulerAngles instance holding the specified Vector3D<Angle> values for the rotation angle elements and the specified Euler order information.
      static EulerAngles valueOf​(Vector3D<javax.measure.quantity.Angle> theta, EulerAngles.Order eulerOrder)
      Returns an EulerAngles instance holding the specified Vector3D<Angle> values for the rotation angle elements and the specified Euler order information.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • valueOf

        public static EulerAngles valueOf​(Vector3D<javax.measure.quantity.Angle> theta,
                                          EulerAngles.Axis initialAxis,
                                          EulerAngles.Parity parity,
                                          boolean repeat1st,
                                          EulerAngles.Frame frame)
        Returns an EulerAngles instance holding the specified Vector3D<Angle> values for the rotation angle elements and the specified Euler order information.
        Parameters:
        theta - The rotation angles about each axis (0=1st axis, 1=2nd axis, 2=3rd axis).
        initialAxis - The initial rotation axis (X, Y, or Z).
        parity - The parity of the axis permutation (EVEN or ODD).
        repeat1st - Repeat the initial axis as the last if true, do not repeat if false.
        frame - The frame from which the axes are taken (STATIC or ROTATING).
        Returns:
        The EulerAngles having the specified values.
      • valueOf

        public static EulerAngles valueOf​(Vector3D<javax.measure.quantity.Angle> theta,
                                          EulerAngles.Order eulerOrder)
        Returns an EulerAngles instance holding the specified Vector3D<Angle> values for the rotation angle elements and the specified Euler order information.
        Parameters:
        theta - The rotation angles about each axis (0=1st axis, 1=2nd axis, 2=3rd axis).
        eulerOrder - The Euler order to use (one of the enumerations in this class).
        Returns:
        The EulerAngles having the specified values.
      • valueOf

        public static EulerAngles valueOf​(Parameter<javax.measure.quantity.Angle> theta1,
                                          Parameter<javax.measure.quantity.Angle> theta2,
                                          Parameter<javax.measure.quantity.Angle> theta3,
                                          EulerAngles.Order eulerOrder)
        Returns an EulerAngles instance holding the specified Parameter<Angle> values for the rotation angle elements and the specified Euler order information.
        Parameters:
        theta1 - The rotation angle about the 1st axis.
        theta2 - The rotation angle about the 2nd axis.
        theta3 - The rotation angle about the 3rd axis.
        eulerOrder - The Euler order to use (one of the enumerations in this class).
        Returns:
        The EulerAngles having the specified values.
      • valueOf

        public static EulerAngles valueOf​(Rotation<?> transform,
                                          EulerAngles.Order order)
        Returns an EulerAngles object constructed from the specified rotation transformation.
        Parameters:
        transform - The rotation transform representing a rotation from frame A to frame B.
        order - The Euler order to use (one of the enumerations in this class).
        Returns:
        The Euler angles representing the specified direction cosine rotation matrix.
      • get

        public Parameter<javax.measure.quantity.Angle> get​(int i)
        Returns the value of an element from this set of Euler angles (0=1st axis, 1=2nd axis, 2=3rd axis).
        Parameters:
        i - the dimension index (0=1st axis, 1=2nd axis, 2=3rd axis).
        Returns:
        the value of the element at i.
        Throws:
        java.lang.IndexOutOfBoundsException - (i < 0) || (i > dimension()-1)
      • getValue

        public double getValue​(int i)
        Returns the value of a floating point number from this set of Euler angles (0=1st axis, 1=2nd axis, 2=3rd axis). This returns the value of the specified Euler angle in whatever the current units of the Euler angles are.
        Parameters:
        i - the floating point number index (0=1st axis, 1=2nd axis, 2=3rd axis).
        Returns:
        the value of the floating point number at i.
        Throws:
        java.lang.IndexOutOfBoundsException - (i < 0) || (i > dimension()-1)
      • getEulerOrder

        public EulerAngles.Order getEulerOrder()
        Returns the Euler order for this set of Euler angles.
        Returns:
        The Euler order for this set of Euler angles.
      • opposite

        public EulerAngles opposite()
        Returns the negation of this set of Euler angles (each angle is negated).
        Returns:
        -this.
      • plus

        public EulerAngles plus​(EulerAngles that)
        Returns the sum of this set of Euler angles with the one specified. The unit of the output set of Euler angles will be the units of this set of Euler angles.
        Parameters:
        that - the Euler angles to be added.
        Returns:
        this + that.
      • plus

        public EulerAngles plus​(Vector<Parameter<javax.measure.quantity.Angle>> that)
        Returns the sum of this set of Euler angles with the one specified. The unit of the output set of Euler angles will be the units of this set of Euler angles.
        Parameters:
        that - the set of Euler angles of angles to be added.
        Returns:
        this + that.
        Throws:
        DimensionException - if vector dimensions are different.
        javax.measure.converter.ConversionException - if the current model does not allow for conversion the units of the input vector to an Angle unit.
      • plus

        public EulerAngles plus​(Parameter<javax.measure.quantity.Angle> that)
        Returns the sum of this set of Euler angles with the angle specified. The input parameter is added to each component of this set of Euler angles. The unit of the output Euler angles will be the units of this set of Euler angles.
        Parameters:
        that - the angle to be added to each element of this set of Euler angles.
        Returns:
        this + that.
      • minus

        public EulerAngles minus​(EulerAngles that)
        Returns the difference between this set of Euler angles and the one specified.
        Parameters:
        that - the Euler angles to be subtracted.
        Returns:
        this - that.
      • minus

        public EulerAngles minus​(Vector<Parameter<javax.measure.quantity.Angle>> that)
        Returns the difference between this set of Euler angles and the one specified.
        Parameters:
        that - the vector of angles to be subtracted.
        Returns:
        this - that.
        Throws:
        DimensionException - if vector dimensions are different.
        javax.measure.converter.ConversionException - if the current model does not allow for conversion the units of the input vector to an Angle unit.
      • minus

        public EulerAngles minus​(Parameter<javax.measure.quantity.Angle> that)
        Subtracts the supplied angle from each element of this set of Euler angles and returns the result. The unit of the output Euler angles will be the units of this set of Euler angles.
        Parameters:
        that - the angle to be subtracted from each element of this set of Euler angles.
        Returns:
        this - that.
      • times

        public EulerAngles times​(double k)
        Returns the product of this set of Euler angles with the specified coefficient.
        Parameters:
        k - the coefficient multiplier.
        Returns:
        this · k
      • divide

        public EulerAngles divide​(double divisor)
        Returns this set of Euler angles with each angle divided by the specified divisor.
        Parameters:
        divisor - the divisor.
        Returns:
        this / divisor.
      • transform

        public <Q extends javax.measure.quantity.Quantity> Vector3D<Q> transform​(Coordinate3D<Q> v)
        Transforms a 3D vector from frame A to B using this set of Euler angles.
        Specified by:
        transform in interface Rotation<EulerAngles>
        Type Parameters:
        Q - The Quantity (unit type) of the input and output vectors.
        Parameters:
        v - the vector expressed in frame A.
        Returns:
        the vector expressed in frame B.
      • times

        public EulerAngles times​(Rotation<?> that)
        Returns the product of this set of Euler angles and the specified rotation transform. If this set of Euler angles is BA and that is AC then the returned value is: BC = BA · AC (or C2B = A2B · C2A).
        Specified by:
        times in interface Rotation<EulerAngles>
        Parameters:
        that - the rotation transform multiplier.
        Returns:
        this · that
      • getUnit

        public javax.measure.unit.Unit<javax.measure.quantity.Angle> getUnit()
        Returns the unit in which the values in this set of Euler angles are stated in.
        Returns:
        The angular unit in which the values in this set of Euler angles are stated.
      • to

        public EulerAngles to​(javax.measure.unit.Unit<javax.measure.quantity.Angle> unit)
        Returns the equivalent to this set of Euler angles but stated in the specified angle unit.
        Parameters:
        unit - the angle unit of the Euler angles to be returned.
        Returns:
        A set of Euler angles equivalent to this set but stated in the specified unit.
        Throws:
        javax.measure.converter.ConversionException - if the current model does not allows for conversion to the specified unit.
      • toFloat64Vector

        public Float64Vector toFloat64Vector()
        Returns the values stored in this set of Euler angles, in the current units, as a Float64Vector with the values ordered (1st axis angle, 2nd axis angle, 3rd axis angle).
        Returns:
        The values stored in this set of Euler angles as a Float64Vector.
      • copy

        public EulerAngles copy()
        Returns a copy of this set of Euler angles allocated by the calling thread (possibly on the stack).
        Specified by:
        copy in interface Rotation<EulerAngles>
        Specified by:
        copy in interface javolution.lang.ValueType
        Returns:
        an identical and independent copy of this set of Euler angles.
      • toText

        public javolution.text.Text toText()
        Returns the text representation of this set of Euler angles.
        Specified by:
        toText in interface javolution.lang.Realtime
        Returns:
        the text representation of this set of Euler angles.
      • equals

        public boolean equals​(java.lang.Object that)
        Compares this EulerAngles against the specified object for strict equality (same rotation type and same values).
        Overrides:
        equals in class java.lang.Object
        Parameters:
        that - the object to compare with.
        Returns:
        true if this rotation is identical to that rotation; false otherwise.
      • hashCode

        public int hashCode()
        Returns the hash code for this rotation.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code value.
      • main

        public static void main​(java.lang.String[] args)
        Tests the methods in this class.
        Parameters:
        args - Command line arguments (ignored)