Class Quaternionf


  • public class Quaternionf
    extends Rotation3DVectorf
    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
      Quaternionf()
      constuct Quaterinion of {0,0,0,1}
      Quaternionf​(float qx, float qy, float qz, float qw)
      Creates a Quaternion
      Quaternionf​(long cPtr, boolean cMemoryOwn)  
      Quaternionf​(Quaternionf quat)
      Creates a Quaternion from another Quaternion
      Quaternionf​(Rotation3Df 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
      Quaternionf add()
      Unary plus.
      void delete()  
      EigenQuaternionf e()
      Convert to an Eigen Quaternion.
      boolean equals​(Quaternionf r)
      Comparison (equals) operator
      float get​(long i)  
      static long getCPtr​(Quaternionf obj)  
      float getLength()
      get length of quaternion
      \sqrt{q_x^2+q_y^2+q_z^2+q_w^2}
      float getLengthSquared()
      get squared length of quaternion
      q_x^2+q_y^2+q_z^2+q_w^2
      float getQw()
      get method for the w component
      float getQx()
      get method for the x component
      float getQy()
      get method for the y component
      float getQz()
      get method for the z component
      Quaternionf multiply​(float s)
      Scalar multiplication.
      Quaternionf 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, float d)  
      long size()
      The dimension of the quaternion (i.e.
      Quaternionf slerp​(Quaternionf v, float 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
      Rotation3Df 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

      • Quaternionf

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

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

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

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

        public Quaternionf​(Rotation3Df 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​(Quaternionf obj)
      • getQx

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

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

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

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

        public float 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 float 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 Rotation3Df toRotation3D()
        Calculates the 3\times 3 Rotation matrix

        Overrides:
        toRotation3D in class Rotation3DVectorf
        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 Quaternionf slerp​(Quaternionf v,
                                 float 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 Quaternionf multiply​(float s)
        Scalar multiplication.
      • equals

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

        public EigenQuaternionf 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 float get​(long i)
      • set

        public void set​(long i,
                        float d)