Class Quaterniond


  • public class Quaterniond
    extends Rotation3DVectord
    A Quaternion \mathbf{q}\in \mathbb{R}^4 a complex
    number used to describe rotations in 3-dimensional space.
    q_w+{\bf i}\ q_x+ {\bf j} q_y+ {\bf k}\ q_z

    Quaternions can be added and multiplied in a similar way as usual
    algebraic numbers. Though there are differences. Quaternion
    multiplication is not commutative which means
    Q\cdot P \neq P\cdot Q
    • Constructor Summary

      Constructors 
      Constructor Description
      Quaterniond()
      constuct Quaterinion of {0,0,0,1}
      Quaterniond​(double qx, double qy, double qz, double qw)
      Creates a Quaternion
      Quaterniond​(long cPtr, boolean cMemoryOwn)  
      Quaterniond​(Quaterniond quat)
      Creates a Quaternion from another Quaternion
      Quaterniond​(Rotation3Dd rot)
      Extracts a Quaternion from Rotation matrix using
      setRotation(const rw::math::Rotation3D<R>& rot)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Quaterniond add()
      Unary plus.
      void delete()  
      EigenQuaterniond e()
      Convert to an Eigen Quaternion.
      boolean equals​(Quaterniond r)
      Comparison (equals) operator
      double get​(long i)  
      static long getCPtr​(Quaterniond obj)  
      double getLength()
      get length of quaternion
      \sqrt{q_x^2+q_y^2+q_z^2+q_w^2}
      double getLengthSquared()
      get squared length of quaternion
      q_x^2+q_y^2+q_z^2+q_w^2
      double getQw()
      get method for the w component
      double getQx()
      get method for the x component
      double getQy()
      get method for the y component
      double getQz()
      get method for the z component
      Quaterniond multiply​(double s)
      Scalar multiplication.
      Quaterniond negate()
      Unary minus.
      void normalize()
      normalizes this quaternion so that
      normalze(Q)=\frac{Q}{\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}}
      void set​(long i, double d)  
      long size()
      The dimension of the quaternion (i.e.
      Quaterniond slerp​(Quaterniond v, double t)
      Calculates a slerp interpolation between this and v.

      The slerp interpolation ensures a constant velocity across the interpolation.
      For t=0 the result is this and for t=1 it is v.

      Note: Algorithm and implementation is thanks to euclideanspace.com
      Rotation3Dd toRotation3D()
      Calculates the 3\times 3 Rotation matrix

      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Quaterniond

        public Quaterniond​(long cPtr,
                           boolean cMemoryOwn)
      • Quaterniond

        public Quaterniond()
        constuct Quaterinion of {0,0,0,1}
      • Quaterniond

        public Quaterniond​(double qx,
                           double qy,
                           double qz,
                           double qw)
        Creates a Quaternion
        Parameters:
        qx - [in] q_x
        qy - [in] q_y
        qz - [in] q_z
        qw - [in] q_w
      • Quaterniond

        public Quaterniond​(Quaterniond quat)
        Creates a Quaternion from another Quaternion
        Parameters:
        quat - [in] Quaternion
      • Quaterniond

        public Quaterniond​(Rotation3Dd rot)
        Extracts a Quaternion from Rotation matrix using
        setRotation(const rw::math::Rotation3D<R>& rot)
        Parameters:
        rot - [in] A 3x3 rotation matrix \mathbf{rot}
    • Method Detail

      • getCPtr

        public static long getCPtr​(Quaterniond obj)
      • getQx

        public double getQx()
        get method for the x component
        Returns:
        the x component of the quaternion
      • getQy

        public double getQy()
        get method for the y component
        Returns:
        the y component of the quaternion
      • getQz

        public double getQz()
        get method for the z component
        Returns:
        the z component of the quaternion
      • getQw

        public double getQw()
        get method for the w component
        Returns:
        the w component of the quaternion
      • getLength

        public double getLength()
        get length of quaternion
        \sqrt{q_x^2+q_y^2+q_z^2+q_w^2}
        Returns:
        the length og this quaternion
      • getLengthSquared

        public double getLengthSquared()
        get squared length of quaternion
        q_x^2+q_y^2+q_z^2+q_w^2
        Returns:
        the length og this quaternion
      • normalize

        public void normalize()
        normalizes this quaternion so that
        normalze(Q)=\frac{Q}{\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}}
      • toRotation3D

        public Rotation3Dd toRotation3D()
        Calculates the 3\times 3 Rotation matrix

        Overrides:
        toRotation3D in class Rotation3DVectord
        Returns:
        A 3x3 rotation matrix \mathbf{rot}
        \mathbf{rot} = \left[ \begin{array}{ccc} 1-2(q_y^2-q_z^2) 2(q_x\ q_y+q_z\ q_w) 2(q_x\ q_z-q_y\ q_w) \\ 2(q_x\ q_y-q_z\ q_w) 1-2(q_x^2-q_z^2) 2(q_y\ q_z+q_x\ q_w)\\ 2(q_x\ q_z+q_y\ q_w) 2(q_y\ q_z-q_x\ q_z) 1-2(q_x^2-q_y^2) \end{array} \right]
      • size

        public long size()
        The dimension of the quaternion (i.e. 4).
        This method is provided to help support generic algorithms using
        size() and operator[].
      • slerp

        public Quaterniond slerp​(Quaterniond v,
                                 double t)
        Calculates a slerp interpolation between this and v.

        The slerp interpolation ensures a constant velocity across the interpolation.
        For t=0 the result is this and for t=1 it is v.

        Note: Algorithm and implementation is thanks to euclideanspace.com
      • multiply

        public Quaterniond multiply​(double s)
        Scalar multiplication.
      • equals

        public boolean equals​(Quaterniond r)
        Comparison (equals) operator
      • e

        public EigenQuaterniond e()
        Convert to an Eigen Quaternion.
        Returns:
        Eigen Quaternion representation.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • get

        public double get​(long i)
      • set

        public void set​(long i,
                        double d)