SOFA API  6a688117 Open source framework for multi-physics simuation
sofa::helper::Quater< Real > Class Template Reference

`#include <Quater.h>`

Inheritance diagram for sofa::helper::Quater< Real >:

Public Member Functions

Quater ()

~Quater ()

Quater (Real x, Real y, Real z, Real w)

template<class Real2 >
Quater (const Real2 q[])

template<class Real2 >
Quater (const Quater< Real2 > &q)

Quater (const defaulttype::Vec< 3, Real > &axis, Real angle)

Quater (const defaulttype::Vec< 3, Real > &vFrom, const defaulttype::Vec< 3, Real > &vTo)

void set (Real x, Real y, Real z, Real w)

const Realptr () const
Cast into a standard C array of elements. More...

Realptr ()
Cast into a standard C array of elements. More...

bool isNormalized ()
Returns true if norm of Quaternion is one, false otherwise. More...

void normalize ()
Normalize a quaternion. More...

void clear ()

void fromFrame (defaulttype::Vec< 3, Real > &x, defaulttype::Vec< 3, Real > &y, defaulttype::Vec< 3, Real > &z)

void fromMatrix (const defaulttype::Matrix3 &m)

template<class Mat33 >
void toMatrix (Mat33 &m) const

template<class Vec >
Vec rotate (const Vec &v) const
Apply the rotation to a given vector. More...

template<class Vec >
Vec inverseRotate (const Vec &v) const
Apply the inverse rotation to a given vector. More...

Quater< Realoperator+ (const Quater< Real > &q1) const

Quater< Realoperator* (const Quater< Real > &q1) const

Quater< Realoperator* (const Real &r) const

Quater< Realoperator/ (const Real &r) const

void operator*= (const Real &r)

void operator/= (const Real &r)

Quater quatVectMult (const defaulttype::Vec< 3, Real > &vect)
Given two Quaters, multiply them together to get a third quaternion. More...

Quater vectQuatMult (const defaulttype::Vec< 3, Real > &vect)

Realoperator[] (size_type index)

const Realoperator[] (size_type index) const

Quater inverse () const

defaulttype::Vec< 3, RealquatToRotationVector () const
Given a quaternion, compute rotation vector (axis times angle) More...

defaulttype::Vec< 3, RealtoEulerVector () const

void slerp (const Quater &a, const Quater &b, Real t, bool allowFlip=true)
Returns the slerp interpolation of Quaternions `a` and `b`, at time `t`. More...

void buildRotationMatrix (Real m[4][4]) const
Build a rotation matrix, given a quaternion rotation. More...

void writeOpenGlMatrix (double *m) const
Write an OpenGL rotation matrix. More...

void writeOpenGlMatrix (float *m) const
Write an OpenGL rotation matrix. More...

Quater axisToQuat (defaulttype::Vec< 3, Real > a, Real phi)
Given an axis and angle, compute quaternion. More...

void quatToAxis (defaulttype::Vec< 3, Real > &a, Real &phi) const
Given a quaternion, compute an axis and angle. More...

Quater quatDiff (Quater a, const Quater &b)
Return the quaternion resulting of the movement between 2 quaternions. More...

defaulttype::Vec< 3, RealangularDisplacement (Quater a, const Quater &b)
Return the eulerian vector resulting of the movement between 2 quaternions. More...

void setFromUnitVectors (const defaulttype::Vec< 3, Real > &vFrom, const defaulttype::Vec< 3, Real > &vTo)
Sets this quaternion to the rotation required to rotate direction vector vFrom to direction vector vTo. vFrom and vTo are assumed to be normalized. More...

void print ()
Print quaternion (C style) More...

Quater< Realslerp (Quater< Real > &q1, Real t)

Quater< Realslerp2 (Quater< Real > &q1, Real t)

void operator+= (const Quater &q2)

void operator*= (const Quater &q2)

bool operator== (const Quater &q) const

bool operator!= (const Quater &q) const

Static Public Member Functions

static Quater identity ()

static Quater createQuaterFromFrame (const defaulttype::Vec< 3, Real > &lox, const defaulttype::Vec< 3, Real > &loy, const defaulttype::Vec< 3, Real > &loz)

template<class V >
static Quater createFromRotationVector (const V &a)
Create using rotation vector (axis*angle) given in parent coordinates. More...

static Quater createQuaterFromEuler (defaulttype::Vec< 3, Real > v, EulerOrder order=EulerOrder::ZYX)

static Quater fromEuler (Real alpha, Real beta, Real gamma, EulerOrder order=EulerOrder::ZYX)
Create a quaternion from Euler angles. More...

template<class T >
static Quater createFromRotationVector (T a0, T a1, T a2)
Create using the entries of a rotation vector (axis*angle) given in parent coordinates. More...

template<class V >
static Quater set (const V &a)
Create using rotation vector (axis*angle) given in parent coordinates. More...

template<class T >
static Quater set (T a0, T a1, T a2)
Create using using the entries of a rotation vector (axis*angle) given in parent coordinates. More...

static unsigned int size ()

Friends

std::ostream & operator<< (std::ostream &out, const Quater &v)
write to an output stream More...

std::istream & operator>> (std::istream &in, Quater &v)
read from an input stream More...

Constructor details

template<class Real >
 sofa::helper::Quater< Real >::Quater ( )
template<class Real >
 sofa::helper::Quater< Real >::~Quater ( )
template<class Real>
 sofa::helper::Quater< Real >::Quater ( Real x, Real y, Real z, Real w )
template<class Real>
template<class Real2 >
 sofa::helper::Quater< Real >::Quater ( const Real2 q[] )
inline
template<class Real>
template<class Real2 >
 sofa::helper::Quater< Real >::Quater ( const Quater< Real2 > & q )
inline
template<class Real>
 sofa::helper::Quater< Real >::Quater ( const defaulttype::Vec< 3, Real > & axis, Real angle )
template<class Real>
 sofa::helper::Quater< Real >::Quater ( const defaulttype::Vec< 3, Real > & vFrom, const defaulttype::Vec< 3, Real > & vTo )
inline

Sets this quaternion to the rotation required to rotate direction vector vFrom to direction vector vTo. vFrom and vTo are assumed to be normalized.

Function details

template<class Real>
 defaulttype::Vec<3,Real> sofa::helper::Quater< Real >::angularDisplacement ( Quater< Real > a, const Quater< Real > & b )
inline

Return the eulerian vector resulting of the movement between 2 quaternions.

template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::axisToQuat ( defaulttype::Vec< 3, Real > a, Real phi )

Given an axis and angle, compute quaternion.

template<class Real>
 void sofa::helper::Quater< Real >::buildRotationMatrix ( Real m[4][4] ) const

Build a rotation matrix, given a quaternion rotation.

template<class Real>
 void sofa::helper::Quater< Real >::clear ( )
inline
template<class Real>
template<class V >
 static Quater sofa::helper::Quater< Real >::createFromRotationVector ( const V & a )
inlinestatic

Create using rotation vector (axis*angle) given in parent coordinates.

template<class Real>
template<class T >
 static Quater sofa::helper::Quater< Real >::createFromRotationVector ( T a0, T a1, T a2 )
inlinestatic

Create using the entries of a rotation vector (axis*angle) given in parent coordinates.

template<class Real>
 static Quater sofa::helper::Quater< Real >::createQuaterFromEuler ( defaulttype::Vec< 3, Real > v, EulerOrder order = `EulerOrder::ZYX` )
inlinestatic
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::createQuaterFromFrame ( const defaulttype::Vec< 3, Real > & lox, const defaulttype::Vec< 3, Real > & loy, const defaulttype::Vec< 3, Real > & loz )
static
template<class Real>
 static Quater sofa::helper::Quater< Real >::fromEuler ( Real alpha, Real beta, Real gamma, EulerOrder order = `EulerOrder::ZYX` )
inlinestatic

Create a quaternion from Euler angles.

template<class Real>
 void sofa::helper::Quater< Real >::fromFrame ( defaulttype::Vec< 3, Real > & x, defaulttype::Vec< 3, Real > & y, defaulttype::Vec< 3, Real > & z )
template<class Real >
 void sofa::helper::Quater< Real >::fromMatrix ( const defaulttype::Matrix3 & m )
template<class Real>
 static Quater sofa::helper::Quater< Real >::identity ( )
inlinestatic
template<class Real >
 Quater< Real > sofa::helper::Quater< Real >::inverse ( ) const
template<class Real>
template<class Vec >
 Vec sofa::helper::Quater< Real >::inverseRotate ( const Vec & v ) const
inline

Apply the inverse rotation to a given vector.

template<class Real >
 bool sofa::helper::Quater< Real >::isNormalized ( )

Returns true if norm of Quaternion is one, false otherwise.

template<class Real >
 void sofa::helper::Quater< Real >::normalize ( )

Normalize a quaternion.

Quater<Real>s always obey: a^2 + b^2 + c^2 + d^2 = 1.0 If they don't add up to 1.0, dividing by their magnitude will renormalize them.

template<class Real>
 bool sofa::helper::Quater< Real >::operator!= ( const Quater< Real > & q ) const
inline
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::operator* ( const Quater< Real > & q1 ) const
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::operator* ( const Real & r ) const
template<class Real>
 void sofa::helper::Quater< Real >::operator*= ( const Real & r )
template<class Real>
 void sofa::helper::Quater< Real >::operator*= ( const Quater< Real > & q2 )
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::operator+ ( const Quater< Real > & q1 ) const

Given two quaternions, add them together to get a third quaternion. Adding quaternions to get a compound rotation is analagous to adding translations to get a compound translation.

Given two rotations, e1 and e2, expressed as quaternion rotations, figure out the equivalent single rotation and stuff it into dest. This routine also normalizes the result every RENORMCOUNT times it is called, to keep error from creeping in. NOTE: This routine is written so that q1 or q2 may be the same as dest (or each other).

template<class Real>
 void sofa::helper::Quater< Real >::operator+= ( const Quater< Real > & q2 )
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::operator/ ( const Real & r ) const
template<class Real>
 void sofa::helper::Quater< Real >::operator/= ( const Real & r )
template<class Real>
 bool sofa::helper::Quater< Real >::operator== ( const Quater< Real > & q ) const
inline
template<class Real>
 Real& sofa::helper::Quater< Real >::operator[] ( size_type index )
inline
template<class Real>
 const Real& sofa::helper::Quater< Real >::operator[] ( size_type index ) const
inline
template<class Real >
 void sofa::helper::Quater< Real >::print ( )

Print quaternion (C style)

template<class Real>
 const Real* sofa::helper::Quater< Real >::ptr ( ) const
inline

Cast into a standard C array of elements.

template<class Real>
 Real* sofa::helper::Quater< Real >::ptr ( )
inline

Cast into a standard C array of elements.

template<class Real>
 Quater sofa::helper::Quater< Real >::quatDiff ( Quater< Real > a, const Quater< Real > & b )
inline

Return the quaternion resulting of the movement between 2 quaternions.

template<class Real>
 void sofa::helper::Quater< Real >::quatToAxis ( defaulttype::Vec< 3, Real > & a, Real & phi ) const

Given a quaternion, compute an axis and angle.

template<class Real >
 defaulttype::Vec< 3, Real > sofa::helper::Quater< Real >::quatToRotationVector ( ) const

Given a quaternion, compute rotation vector (axis times angle)

template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::quatVectMult ( const defaulttype::Vec< 3, Real > & vect )

Given two Quaters, multiply them together to get a third quaternion.

template<class Real>
template<class Vec >
 Vec sofa::helper::Quater< Real >::rotate ( const Vec & v ) const
inline

Apply the rotation to a given vector.

template<class Real>
 void sofa::helper::Quater< Real >::set ( Real x, Real y, Real z, Real w )
inline
template<class Real>
template<class V >
 static Quater sofa::helper::Quater< Real >::set ( const V & a )
inlinestatic

Create using rotation vector (axis*angle) given in parent coordinates.

template<class Real>
template<class T >
 static Quater sofa::helper::Quater< Real >::set ( T a0, T a1, T a2 )
inlinestatic

Create using using the entries of a rotation vector (axis*angle) given in parent coordinates.

template<class Real>
 void sofa::helper::Quater< Real >::setFromUnitVectors ( const defaulttype::Vec< 3, Real > & vFrom, const defaulttype::Vec< 3, Real > & vTo )
inline

Sets this quaternion to the rotation required to rotate direction vector vFrom to direction vector vTo. vFrom and vTo are assumed to be normalized.

template<class Real>
 static unsigned int sofa::helper::Quater< Real >::size ( void )
inlinestatic
template<class Real>
 void sofa::helper::Quater< Real >::slerp ( const Quater< Real > & a, const Quater< Real > & b, Real t, bool allowFlip = `true` )

Returns the slerp interpolation of Quaternions `a` and `b`, at time `t`.

`t` should range in [0,1]. Result is `a` when `t=0` and `b` when `t=1`.

When `allowFlip` is `true` (default) the slerp interpolation will always use the "shortest path" between the Quaternions' orientations, by "flipping" the source Quaternion if needed (see negate()).

template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::slerp ( Quater< Real > & q1, Real t )
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::slerp2 ( Quater< Real > & q1, Real t )
template<class Real >
 defaulttype::Vec< 3, Real > sofa::helper::Quater< Real >::toEulerVector ( ) const

Compute the Euler angles: Roll: rotation about the X-axis Pitch: rotation about the Y-axis Yaw: rotation about the Z-axis

template<class Real>
template<class Mat33 >
 void sofa::helper::Quater< Real >::toMatrix ( Mat33 & m ) const
inline
template<class Real>
 Quater< Real > sofa::helper::Quater< Real >::vectQuatMult ( const defaulttype::Vec< 3, Real > & vect )
template<class Real >
 void sofa::helper::Quater< Real >::writeOpenGlMatrix ( double * m ) const

Write an OpenGL rotation matrix.

Write an OpenGL rotation matrix

template<class Real >
 void sofa::helper::Quater< Real >::writeOpenGlMatrix ( float * m ) const

Write an OpenGL rotation matrix.

Enum details

template<class Real>
 anonymous enum
Enumerator
static_size
template<class Real>
 anonymous enum

Compile-time constant specifying the number of scalars within this vector (equivalent to the size() method)

Enumerator
total_size
template<class Real>
 anonymous enum

Compile-time constant specifying the number of dimensions of space (NOT equivalent to total_size for quaternions)

Enumerator
spatial_dimensions
template<class Real>
 strong

Create a quaternion from Euler angles Thanks to https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L199

Enumerator
XYZ
YXZ
ZXY
ZYX
YZX
XZY
NONE

Related details

template<class Real>
 std::ostream& operator<< ( std::ostream & out, const Quater< Real > & v )
friend

write to an output stream

template<class Real>
 std::istream& operator>> ( std::istream & in, Quater< Real > & v )
friend