Momentum Scripting v1
Loading...
Searching...
No Matches
MOMENTUM_NAMESPACE::EulerAngles Class Reference

#include <EulerAngles.h>

Classes

class  EulerOrder
 

Public Member Functions

 EulerAngles (const EulerAngles &e)
 
 EulerAngles (const Matrix4x4 &m, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 
 EulerAngles (const Quat &q, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 
 EulerAngles (const Vec3 &angles, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 
 EulerAngles (double a, double b, double c, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 
 EulerAngles (double a, double b, double c, int C)
 
 EulerAngles (EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 
Vec3 asVec3 () const
 
std::pair< Matrix4x4, bool > getAsMatrix4x4 (Matrix4x4 matrix) const
 
std::pair< Quat, bool > getAsQuat () const
 
const EulerAngles::EulerOrdergetOrder () const
 
EulerAngles operator= (const EulerAngles &e)
 
double & operator[] (int i)
 
double operator[] (int i) const
 
void set (const Matrix4x4 &m, EulerConvention::Convention C=EulerConvention::BAD)
 
void set (const Quat &q, EulerConvention::Convention C=EulerConvention::BAD)
 
void set (const Vec3 &angles)
 
void set (double x, double y, double z)
 
const EulerAngles::EulerOrdersetOrder (const EulerAngles::EulerOrder &order)
 
double setX (double val)
 
double setY (double val)
 
double setZ (double val)
 
double x () const
 
double y () const
 
double z () const
 

Static Public Member Functions

static EulerAngles random (const Vec3 &min=Vec3(double(0.0)), const Vec3 &max=Vec3(2 *MOMENTUM_NAMESPACE::PI), EulerConvention::Convention c=EulerConvention::DEFAULT_CONVENTION)
 

Detailed Description

This class provides conversion services between Euler angles in any of the 24 conventions and corresponding quaternions.

There are 24 distinct Euler angles conventions which can be used to parameterize this class. Each of them has a singularity line in which only the sum of two of the angles is relevant to the final rotation matrix (or quaternion). Euler angles are defined as three successive rotations along three successive axes, no two successive ones being identical. This results in 12 different choice of axis sequence. Given that we can choose the reference axes or the rotated ones, this leads to 12 choices with co-rotated axes, 12 choices for fixed axes.

The different conventions are labeled so that it is easy to extract the Real nature of each of them. Following Shoemake, the last bit is used to indicate whether we are using the static or rotated frame for the coordinate axes. The next bit indicates whether the first axis is repeated as the last. The next bit is the parity of the axis sequence. The next 3 bits indicate the first axis which is either 0, 1 or 2. That information is then used to reduce the number of conventions to just two: repeated axes or non-repeated axes. Computations are made using permutations so only two computations are needed. The distinction between static axes and moving axes corresponds to an inversion of the permutation. Negative parities just negate all the angles. These last two operations are easily performed at the end of a computation.

When computing a transform matrix from a given EulerAngles, the resulting matrix transforms the coordinates of a given vector from the body frame to the world frame. However, in accordance to the OpenGL convention, the matrix is to be multiplied from the left which amounts to transposing.

Constructor & Destructor Documentation

◆ EulerAngles() [1/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION)

Default constructor.

Convention is set to EulerConvention::DEFAULT_CONVENTION and angles are set to 0. Convention is set to C and angles are set to 0.

◆ EulerAngles() [2/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( const EulerAngles e)

Copy constructor.

◆ EulerAngles() [3/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( double  a,
double  b,
double  c,
int  C 
)

Explicit constructor.

◆ EulerAngles() [4/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( double  a,
double  b,
double  c,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)

Explicit constructor.

◆ EulerAngles() [5/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( const Vec3 angles,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)
explicit

Explicit constructor.

◆ EulerAngles() [6/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( const Matrix4x4 m,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)

Construct from affine matrix in given convention.

◆ EulerAngles() [7/7]

MOMENTUM_NAMESPACE::EulerAngles::EulerAngles ( const Quat q,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)

Construct from quaternion in given convention.

Member Function Documentation

◆ asVec3()

Vec3 MOMENTUM_NAMESPACE::EulerAngles::asVec3 ( ) const
Returns
the vector part (x,y,z) as a Vec3

◆ getAsMatrix4x4()

std::pair< Matrix4x4, bool > MOMENTUM_NAMESPACE::EulerAngles::getAsMatrix4x4 ( Matrix4x4  matrix) const

Compute the value of matrix m that corresponds to current angles in current convention.

Returns
std::pair where first item is the matrix and second is a bool which indicates if the conversion was successful

◆ getAsQuat()

std::pair< Quat, bool > MOMENTUM_NAMESPACE::EulerAngles::getAsQuat ( ) const

Compute the value of quaternion q that corresponds to current angles in current convention.

Returns
std::pair where first item is the quaternion and second is a bool which indicates if the conversion was successful

◆ getOrder()

const EulerAngles::EulerOrder & MOMENTUM_NAMESPACE::EulerAngles::getOrder ( ) const

Get or set the convention.

◆ operator=()

EulerAngles MOMENTUM_NAMESPACE::EulerAngles::operator= ( const EulerAngles e)

Assignment operator.

◆ operator[]() [1/2]

double & MOMENTUM_NAMESPACE::EulerAngles::operator[] ( int  i)

Get an element by index as a reference.

◆ operator[]() [2/2]

double MOMENTUM_NAMESPACE::EulerAngles::operator[] ( int  i) const

Get an element by index.

◆ random()

static EulerAngles MOMENTUM_NAMESPACE::EulerAngles::random ( const Vec3 min = Vec3(double(0.0)),
const Vec3 max = Vec3(2 *MOMENTUM_NAMESPACE::PI),
EulerConvention::Convention  c = EulerConvention::DEFAULT_CONVENTION 
)
static

◆ set() [1/4]

void MOMENTUM_NAMESPACE::EulerAngles::set ( const Matrix4x4 m,
EulerConvention::Convention  C = EulerConvention::BAD 
)

Set the angles to correspond to matrix m in given convention.

By default, the convention used is the value stored in the present object. If the last argument is used, the convention is changed to the given value.

◆ set() [2/4]

void MOMENTUM_NAMESPACE::EulerAngles::set ( const Quat q,
EulerConvention::Convention  C = EulerConvention::BAD 
)

Set the angles to correspond to quaternion q in given convention.

By default, the convention used is the value stored in the present object. If the last argument is used, the convention is changed to the given value.

◆ set() [3/4]

void MOMENTUM_NAMESPACE::EulerAngles::set ( const Vec3 angles)

Set the three angles in one call.

Parameters
angles- Angles specified in radians.

◆ set() [4/4]

void MOMENTUM_NAMESPACE::EulerAngles::set ( double  x,
double  y,
double  z 
)

Set the three angles in one call.

Parameters
x,y,z- Angles specified in radians.

◆ setOrder()

const EulerAngles::EulerOrder & MOMENTUM_NAMESPACE::EulerAngles::setOrder ( const EulerAngles::EulerOrder order)

Get the convention.

◆ setX()

double MOMENTUM_NAMESPACE::EulerAngles::setX ( double  val)

Get or set the first angle.

◆ setY()

double MOMENTUM_NAMESPACE::EulerAngles::setY ( double  val)

Get or set the second angle.

◆ setZ()

double MOMENTUM_NAMESPACE::EulerAngles::setZ ( double  val)

Get or set the third angle.

◆ x()

double MOMENTUM_NAMESPACE::EulerAngles::x ( ) const

Get the first angle.

◆ y()

double MOMENTUM_NAMESPACE::EulerAngles::y ( ) const

Get the second angle.

◆ z()

double MOMENTUM_NAMESPACE::EulerAngles::z ( ) const

Get the third angle.