My Project
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
Quaternionoperator*= (const Quaternion &other)
Quaternionoperator+= (const Quaternion &other)
Quaternionoperator-= (const Quaternion &other)
void print (std::ostream &os) const
 Quaternion ()
 Quaternion (const C3DDMatrix &rot)
 Quaternion (const C3DDVector &rot)
 Quaternion (const C3DFMatrix &rot)
 Quaternion (const Quaternion &other)=default
 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.

Referenced by inverse(), operator*=(), operator+=(), operator-=(), operator==, and Quaternion().

◆ Quaternion() [2/6]

Quaternion::Quaternion ( const Quaternion & other)
default

The copy constructor.

Parameters
other

References Quaternion().

◆ 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.

References w(), x(), y(), and z().

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

References Quaternion().

◆ 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

References Quaternion().

◆ operator+=()

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

in-place adding

Parameters
other
Returns
reference to the updated quaternion

References Quaternion().

◆ operator-=()

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

in-place substraction

Parameters
other
Returns
reference to the updated quaternion

References Quaternion().

◆ print()

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

Print the quaternion to an output stream

Parameters
osthe output stream

References w(), x(), y(), and z().

Referenced by operator<<().

◆ w()

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

Definition at line 160 of file quaternion.hh.

Referenced by print(), and Quaternion().

◆ x()

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

Definition at line 165 of file quaternion.hh.

Referenced by print(), and Quaternion().

◆ y()

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

Definition at line 170 of file quaternion.hh.

Referenced by print(), and Quaternion().

◆ z()

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

Definition at line 175 of file quaternion.hh.

Referenced by print(), and Quaternion().

◆ operator==

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

References Quaternion().

Field Documentation

◆ _1

const Quaternion Quaternion::_1
static

Definition at line 149 of file quaternion.hh.


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