KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Public Types | Public Member Functions | List of all members
Kratos::Quaternion< T > Class Template Reference

Quaternion A simple class that implements the main features of quaternion algebra. More...

#include <quaternion.h>

Collaboration diagram for Kratos::Quaternion< T >:

Public Types

typedef T value_type
 
typedef value_typereference
 
typedef value_type const & const_reference
 

Public Member Functions

 KRATOS_CLASS_POINTER_DEFINITION (Quaternion)
 
virtual ~Quaternion ()
 Destructor. More...
 
virtual void PrintInfo (std::ostream &rOStream) const
 
virtual void PrintData (std::ostream &rOStream) const
 Print object's data. More...
 
Life Cycle
 Quaternion ()
 
 Quaternion (T w, T x, T y, T z)
 
 Quaternion (const Quaternion &other)
 
Operators
Quaternionoperator= (const Quaternion &other)
 
const_reference operator[] (size_t i) const
 
reference operator[] (size_t i)
 
template<class AE >
BOOST_UBLAS_INLINE Quaternionoperator= (const boost::numeric::ublas::vector_expression< AE > &ae)
 
Access
 KRATOS_DEPRECATED_MESSAGE ("Deprecated method due to style") inline const T x() const
 
const T X () const
 
void SetX (const T &value)
 
 KRATOS_DEPRECATED_MESSAGE ("Deprecated method due to style") inline const T y() const
 
const T Y () const
 
void SetY (const T &value)
 
 KRATOS_DEPRECATED_MESSAGE ("Deprecated method due to style") inline const T z() const
 
const T Z () const
 
void SetZ (const T &value)
 
 KRATOS_DEPRECATED_MESSAGE ("Deprecated method due to style") inline const T w() const
 
const T W () const
 
void SetW (const T &value)
 
Operations
const T squaredNorm () const
 
const T norm () const
 
void normalize ()
 
Quaternion conjugate () const
 
template<class TMatrix3x3 >
void ToRotationMatrix (TMatrix3x3 &R) const
 
void ToEulerAngles (array_1d< double, 3 > &EA) const
 
void ToRotationVector (T &rx, T &ry, T &rz) const
 
template<class TVector3 >
void ToRotationVector (TVector3 &v) const
 
template<class TVector3_A , class TVector3_B >
void RotateVector3 (const TVector3_A &a, TVector3_B &b) const
 
template<class TVector3 >
void RotateVector3 (TVector3 &a) const
 

Static Public Member Functions

Static Operations
static Quaternion Identity ()
 
static Quaternion FromAxisAngle (T x, T y, T z, T radians)
 
static Quaternion FromRotationVector (T rx, T ry, T rz)
 
template<class TVector3 >
static Quaternion FromRotationVector (const TVector3 &v)
 
template<class TMatrix3x3 >
static Quaternion FromRotationMatrix (const TMatrix3x3 &m)
 
static Quaternion FromEulerAngles (const array_1d< double, 3 > &EA)
 

Serialization

class Serializer
 

Detailed Description

template<class T>
class Kratos::Quaternion< T >

Quaternion A simple class that implements the main features of quaternion algebra.

Member Typedef Documentation

◆ const_reference

template<class T >
typedef value_type const& Kratos::Quaternion< T >::const_reference

◆ reference

template<class T >
typedef value_type& Kratos::Quaternion< T >::reference

◆ value_type

template<class T >
typedef T Kratos::Quaternion< T >::value_type

Constructor & Destructor Documentation

◆ Quaternion() [1/3]

template<class T >
Kratos::Quaternion< T >::Quaternion ( )
inline

Creates a Zero Quaternion.

◆ Quaternion() [2/3]

template<class T >
Kratos::Quaternion< T >::Quaternion ( w,
x,
y,
z 
)
inline

Creates a Quaternion from its coefficients.

Parameters
ww coefficient
xx coefficient
yy coefficient
zz coefficient

◆ Quaternion() [3/3]

template<class T >
Kratos::Quaternion< T >::Quaternion ( const Quaternion< T > &  other)
inline

Creates a Quaternion from another Quaternion.

Parameters
otherthe other Quaternion

◆ ~Quaternion()

template<class T >
virtual Kratos::Quaternion< T >::~Quaternion ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ conjugate()

template<class T >
Quaternion Kratos::Quaternion< T >::conjugate ( ) const
inline

Returns the Conjugate of this Quaternion, which represents the opposite rotation

Returns
the Conjugate of this Quaternion

◆ FromAxisAngle()

template<class T >
static Quaternion Kratos::Quaternion< T >::FromAxisAngle ( x,
y,
z,
radians 
)
inlinestatic

Returns a Quaternion that represents a rotation of an angle 'radians' around the axis (x, y, z)

Parameters
xthe x component of the rotation axis
ythe y component of the rotation axis
zthe z component of the rotation axis
radiansthe rotation angle in radians
Returns
a Quaternion that represents a rotation of an angle 'radians' around the axis (x, y, z)

◆ FromEulerAngles()

template<class T >
static Quaternion Kratos::Quaternion< T >::FromEulerAngles ( const array_1d< double, 3 > &  EA)
inlinestatic

Returns a Quaternion from Euler Angles. Euler Angles expresed in Z(-X)Z sequence as in GiD

Parameters
EAthe source rotation Euler Angles
Returns
a Quaternion from a Euler Angles

◆ FromRotationMatrix()

template<class T >
template<class TMatrix3x3 >
static Quaternion Kratos::Quaternion< T >::FromRotationMatrix ( const TMatrix3x3 &  m)
inlinestatic

Returns a Quaternion from a Rotation Matrix. The rotation matrix type is the template argument, no check is made on the type of this matrix. These assumptions are made: The matrix should provide an indexed access like m(i, j) where i and j are indices from 0 to 2. This means that the input matrix is a C-Style 3x3 Matrix.

Parameters
mthe source rotation matrix
Returns
a Quaternion from a Rotation Matrix

◆ FromRotationVector() [1/2]

template<class T >
template<class TVector3 >
static Quaternion Kratos::Quaternion< T >::FromRotationVector ( const TVector3 &  v)
inlinestatic

Returns a Quaternion from a rotation vector. The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
vthe source rotation vector
Returns
a Quaternion from a rotation vector

◆ FromRotationVector() [2/2]

template<class T >
static Quaternion Kratos::Quaternion< T >::FromRotationVector ( rx,
ry,
rz 
)
inlinestatic

Returns a Quaternion from a rotation vector

Parameters
rxthe x component of the source rotation vector
rythe y component of the source rotation vector
rzthe z component of the source rotation vector
Returns
a Quaternion from a rotation vector

◆ Identity()

template<class T >
static Quaternion Kratos::Quaternion< T >::Identity ( )
inlinestatic

Returns the Identity Quaternion (i.e. a Quaternion that represents a Zero rotation)

Returns
the Identity Quaternion

◆ KRATOS_CLASS_POINTER_DEFINITION()

template<class T >
Kratos::Quaternion< T >::KRATOS_CLASS_POINTER_DEFINITION ( Quaternion< T >  )

◆ KRATOS_DEPRECATED_MESSAGE() [1/4]

template<class T >
Kratos::Quaternion< T >::KRATOS_DEPRECATED_MESSAGE ( "Deprecated method due to style"  ) const
inline

Returns the W coefficient of this quaternion.

Returns
the W coefficient of this quaternion.

◆ KRATOS_DEPRECATED_MESSAGE() [2/4]

template<class T >
Kratos::Quaternion< T >::KRATOS_DEPRECATED_MESSAGE ( "Deprecated method due to style"  ) const
inline

Returns the X coefficient of this quaternion.

Returns
the X coefficient of this quaternion.

◆ KRATOS_DEPRECATED_MESSAGE() [3/4]

template<class T >
Kratos::Quaternion< T >::KRATOS_DEPRECATED_MESSAGE ( "Deprecated method due to style"  ) const
inline

Returns the Y coefficient of this quaternion.

Returns
the Y coefficient of this quaternion.

◆ KRATOS_DEPRECATED_MESSAGE() [4/4]

template<class T >
Kratos::Quaternion< T >::KRATOS_DEPRECATED_MESSAGE ( "Deprecated method due to style"  ) const
inline

Returns the Z coefficient of this quaternion.

Returns
the Z coefficient of this quaternion.

◆ norm()

template<class T >
const T Kratos::Quaternion< T >::norm ( ) const
inline

Returns the norm of this quaternion. sqrt(x*x + y*y + z*z + w*w)

Returns
the norm of this quaternion.

◆ normalize()

template<class T >
void Kratos::Quaternion< T >::normalize ( )
inline

Makes this Quaternion a Unit Quaternion. If this Quaternion is already normalized this is a no-op

◆ operator=() [1/2]

template<class T >
template<class AE >
BOOST_UBLAS_INLINE Quaternion& Kratos::Quaternion< T >::operator= ( const boost::numeric::ublas::vector_expression< AE > &  ae)
inline

◆ operator=() [2/2]

template<class T >
Quaternion& Kratos::Quaternion< T >::operator= ( const Quaternion< T > &  other)
inline

Copies a Quaternion.

Parameters
otherthe other Quaternion

◆ operator[]() [1/2]

template<class T >
reference Kratos::Quaternion< T >::operator[] ( size_t  i)
inline

◆ operator[]() [2/2]

template<class T >
const_reference Kratos::Quaternion< T >::operator[] ( size_t  i) const
inline

◆ PrintData()

template<class T >
virtual void Kratos::Quaternion< T >::PrintData ( std::ostream &  rOStream) const
inlinevirtual

Print object's data.

◆ PrintInfo()

template<class T >
virtual void Kratos::Quaternion< T >::PrintInfo ( std::ostream &  rOStream) const
inlinevirtual

◆ RotateVector3() [1/2]

template<class T >
template<class TVector3_A , class TVector3_B >
void Kratos::Quaternion< T >::RotateVector3 ( const TVector3_A &  a,
TVector3_B &  b 
) const
inline

Rotates a vector using this quaternion. Note: this is faster than constructing the rotation matrix and perform the matrix multiplication for a single vector. The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
athe input source vector
bthe output rotated vector

◆ RotateVector3() [2/2]

template<class T >
template<class TVector3 >
void Kratos::Quaternion< T >::RotateVector3 ( TVector3 &  a) const
inline

Rotates a vector using this quaternion. Note: this is faster than constructing the rotation matrix and perform the matrix multiplication for a single vector. The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
athe input source vector - rotated on exit

◆ SetW()

template<class T >
void Kratos::Quaternion< T >::SetW ( const T &  value)
inline

◆ SetX()

template<class T >
void Kratos::Quaternion< T >::SetX ( const T &  value)
inline

◆ SetY()

template<class T >
void Kratos::Quaternion< T >::SetY ( const T &  value)
inline

◆ SetZ()

template<class T >
void Kratos::Quaternion< T >::SetZ ( const T &  value)
inline

◆ squaredNorm()

template<class T >
const T Kratos::Quaternion< T >::squaredNorm ( ) const
inline

Returns the squared norm of this quaternion. x*x + y*y + z*z + w*w

Returns
the squared norm of this quaternion.

◆ ToEulerAngles()

template<class T >
void Kratos::Quaternion< T >::ToEulerAngles ( array_1d< double, 3 > &  EA) const
inline

Constructs the Euler Angles from this Quaternion. Euler Angles expresed in Z(-X)Z sequence as in GiD

Parameters
EAthe output rotation matrix

◆ ToRotationMatrix()

template<class T >
template<class TMatrix3x3 >
void Kratos::Quaternion< T >::ToRotationMatrix ( TMatrix3x3 &  R) const
inline

Constructs a Rotation Matrix from this Quaternion. The rotation matrix type is the template argument, no check is made on the type of this matrix. These assumptions are made: The matrix should provide an indexed access like m(i, j) where i and j are indices from 0 to 2. This means that the input matrix is a C-Style 3x3 Matrix. All the 9 coefficients are properly set so there's no need to set the matrix to Zero before calling this function.

Parameters
Rthe output rotation matrix

◆ ToRotationVector() [1/2]

template<class T >
void Kratos::Quaternion< T >::ToRotationVector ( T &  rx,
T &  ry,
T &  rz 
) const
inline

Extracts the Rotation Vector from this Quaternion

Parameters
rxthe output x component if the rotation vector
rythe output y component if the rotation vector
rzthe output z component if the rotation vector

◆ ToRotationVector() [2/2]

template<class T >
template<class TVector3 >
void Kratos::Quaternion< T >::ToRotationVector ( TVector3 &  v) const
inline

Extracts the Rotation Vector from this Quaternion The vector type is the template parameter. No check is made on this type. The following assumptions are made: The vector type should provide indexing like vector(i) where i goes from 0 to 2. (i.e. a C-Style vector of size 3)

Parameters
vthe output rotation vector

◆ W()

template<class T >
const T Kratos::Quaternion< T >::W ( ) const
inline

◆ X()

template<class T >
const T Kratos::Quaternion< T >::X ( ) const
inline

◆ Y()

template<class T >
const T Kratos::Quaternion< T >::Y ( ) const
inline

◆ Z()

template<class T >
const T Kratos::Quaternion< T >::Z ( ) const
inline

Friends And Related Function Documentation

◆ Serializer

template<class T >
friend class Serializer
friend

The documentation for this class was generated from the following file: