Quaternion Class Reference

a class to implement a quaternion More...

#include <mia/3d/quaternion.hh>

Collaboration diagram for Quaternion:
[legend]

Public Member Functions

C3DDVector get_euler_angles () const
 
const C3DDMatrix get_rotation_matrix () const
 
Quaternion inverse () const
 
double norm () const
 
void normalize ()
 normalizes to quaternion More...
 
Quaternionoperator*= (const Quaternion &other)
 
Quaternionoperator+= (const Quaternion &other)
 
Quaternionoperator-= (const Quaternion &other)
 
void print (std::ostream &os) const
 
 Quaternion ()
 
 Quaternion (const Quaternion &other)=default
 
 Quaternion (const C3DDVector &rot)
 
 Quaternion (const C3DFMatrix &rot)
 
 Quaternion (const C3DDMatrix &rot)
 
 Quaternion (double w, double x, double y, double z)
 
double w () const
 
double x () const
 
double y () const
 
double z () const
 

Static Public Attributes

static const Quaternion _1
 

Friends

bool operator== (const Quaternion &a, const Quaternion &b)
 

Detailed Description

a class to implement a quaternion

This class implements some operations of a quaternion. The rotation is implemented as clockwise/left-handed rotation.

Definition at line 43 of file quaternion.hh.

Constructor & Destructor Documentation

◆ Quaternion() [1/6]

Quaternion::Quaternion ( )

The standard constructor that sets all values of the quaternion to zero.

◆ Quaternion() [2/6]

Quaternion::Quaternion ( const Quaternion other)
default

The copy constructor.

Parameters
other

◆ Quaternion() [3/6]

Quaternion::Quaternion ( const C3DDVector rot)

This constructor creates a quaternion from three Euler angles that are applied with the x-y-z convention.

Parameters
rot

◆ Quaternion() [4/6]

Quaternion::Quaternion ( const C3DFMatrix rot)

This constructor creates a quaternion from a 3x3 rotation matrix. If mat3x3 is not a true rotation matrix, then this constructor evaluates the rotation quaternion that best resembles the matrix transformation.

Parameters
rot

◆ Quaternion() [5/6]

Quaternion::Quaternion ( const C3DDMatrix rot)

This constructor creates a quaternion from a 3x3 rotation matrix. If mat3x3 is not a true rotation matrix, then this constructor evaluates the rotation quaternion that best resembles the matrix transformation.

Parameters
rot

◆ Quaternion() [6/6]

Quaternion::Quaternion ( double  w,
double  x,
double  y,
double  z 
)

Constructor to create a quaternion by directly setting its elements.

Member Function Documentation

◆ get_euler_angles()

C3DDVector Quaternion::get_euler_angles ( ) const
Returns
the Euler angles that correspond to the rotation described by this quaternion

◆ get_rotation_matrix()

const C3DDMatrix Quaternion::get_rotation_matrix ( ) const

◆ inverse()

Quaternion Quaternion::inverse ( ) const
Returns
the inverse of the quaternion assuming it is normalized

◆ norm()

double Quaternion::norm ( ) const
Returns
the norm of the quaternion

◆ normalize()

void Quaternion::normalize ( )

normalizes to quaternion

◆ operator*=()

Quaternion& Quaternion::operator*= ( const Quaternion other)

in-place multiplication

Parameters
other
Returns
reference to the updated quaternion

◆ operator+=()

Quaternion& Quaternion::operator+= ( const Quaternion other)

in-place adding

Parameters
other
Returns
reference to the updated quaternion

◆ operator-=()

Quaternion& Quaternion::operator-= ( const Quaternion other)

in-place substraction

Parameters
other
Returns
reference to the updated quaternion

◆ print()

void Quaternion::print ( std::ostream &  os) const

Print the quaternion to an output stream

Parameters
osthe output stream

Referenced by operator<<().

◆ w()

double Quaternion::w ( ) const
inline
Returns
the w- or $x_0$ component of the quaternion

Definition at line 159 of file quaternion.hh.

◆ x()

double Quaternion::x ( ) const
inline
Returns
the x- or $x_1$ component of the quaternion

Definition at line 164 of file quaternion.hh.

◆ y()

double Quaternion::y ( ) const
inline
Returns
the y- or $x_2$ component of the quaternion

Definition at line 169 of file quaternion.hh.

◆ z()

double Quaternion::z ( ) const
inline
Returns
the z- or $x_3$ component of the quaternion

Definition at line 174 of file quaternion.hh.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const Quaternion a,
const Quaternion b 
)
friend
Parameters
a
b
Returns
true if the quaternions are element-wise equal

Field Documentation

◆ _1

const Quaternion Quaternion::_1
static

Definition at line 148 of file quaternion.hh.


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