Class Quaternion_f


  • public class Quaternion_f
    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 Detail

      • Quaternion_f

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

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

        public Quaternion_f​(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
      • Quaternion_f

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

        public Quaternion_f​(Rotation3DVectorf rot)
        Creates a Quaternion from another Rotation3DVector type
        Parameters:
        rot - [in] The Rotation3DVector type
      • Quaternion_f

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

        public Quaternion_f​(EigenQuaternionf r)
        Creates a Quaternion from a Eigen quaternion
        Parameters:
        r - [in] a boost quaternion
    • Method Detail

      • getCPtr

        public static long getCPtr​(Quaternion_f 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
      • get

        public float get​(long i)
      • set

        public void set​(long i,
                        float d)
      • 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[].
      • e

        public EigenQuaternionf e()
        Convert to an Eigen Quaternion.
        Returns:
        Eigen Quaternion representation.
      • multiply

        public Quaternion_f multiply​(float s)
        Scalar multiplication.
      • divide

        public Quaternion_f divide​(float s)
        Scalar Devision.
      • elemDivide

        public Quaternion_f elemDivide​(float lhs)
        element whise division
        Parameters:
        lhs - [in] the scalar to devide with
        Returns:
        the result of elementwise devision
      • 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}}
      • slerp

        public Quaternion_f slerp​(Quaternion_f 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
      • inverse

        public Quaternion_f inverse()
        Calculate the inverse Quaternion
        Returns:
        the inverse quaternion
      • ln

        public Quaternion_f ln()
        calculates the natural logerithm of this quaternion
        Returns:
        natural logetihm
      • pow

        public Quaternion_f pow​(double power)
        calculates the quaternion lifted to the power of power
        Parameters:
        power - [in] the power the quaternion is lifted to
        Returns:
        Quaternion^power
      • copy

        public void copy​(EigenQuaternionf r)
        copy a boost quaternion to this Quaternion
        Parameters:
        r - [in] - boost quaternion
      • multiplyAssign

        public Quaternion_f multiplyAssign​(float s)
        Scalar multiplication.
      • equals

        public boolean equals​(Quaternion_f r)
        Comparison (equals) operator
      • notEqual

        public boolean notEqual​(Quaternion_f r)
        Comparison (not equals) operator
      • toString

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