AGX Dynamics 2.40.1.2
Loading...
Searching...
No Matches
agx::EulerAngles Class Reference

This class provides conversion services between Euler angles in any of the 24 conventions and corresponding quaternions and orthogonal 3x3 matrices. More...

#include <EulerAngles.h>

Classes

class  EulerOrder
 

Public Member Functions

 EulerAngles (const agx::Vec3 &angles, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 Explicit constructor.
 
 EulerAngles (const EulerAngles &e)=default
 Convention is set to C and angles are set to 0.
 
template<typename T >
 EulerAngles (const Matrix3x3T< T > &m, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 Construct from 3x3 Matrix in given convention.
 
template<typename T >
 EulerAngles (const Matrix4x4T< T > &m, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 Construct from 4x4 matrix in given convention.
 
 EulerAngles (const OrthoMatrix3x3 &m, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 
 EulerAngles (const Quat &q, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 Construct from quaternion in given convention.
 
 EulerAngles (EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 Default constructor.
 
 EulerAngles (Real a, Real b, Real c, EulerConvention::Convention C=EulerConvention::DEFAULT_CONVENTION)
 Explicit constructor.
 
 EulerAngles (Real a, Real b, Real c, int C)
 Explicit constructor.
 
template<typename T >
bool get (Matrix3x3T< T > &m) const
 Compute the value of matrix m that corresponds to current angles in current convention.
 
template<typename T >
bool get (Matrix4x4T< T > &m) const
 Compute the value of matrix m that corresponds to current angles in current convention.
 
bool get (OrthoMatrix3x3 &m) const
 
bool get (Quat &q) const
 Compute the value of quaternion q that corresponds to current angles in current convention.
 
EulerAngles::EulerOrdergetOrder ()
 Get the convention.
 
const EulerAngles::EulerOrdergetOrder () const
 Get or set the convention.
 
EulerAnglesoperator= (const EulerAngles &e)=default
 Assignment operator.
 
Realoperator[] (size_t i)
 Get an element by index as a reference.
 
Real operator[] (size_t i) const
 Get an element by index.
 
Realptr ()
 
const Realptr () const
 
template<typename T >
EulerAnglesset (const Matrix3x3T< T > &m, EulerConvention::Convention C=EulerConvention::BAD)
 Set the angles to correspond to matrix m in given convention.
 
template<typename T >
EulerAnglesset (const Matrix4x4T< T > &m, EulerConvention::Convention c=EulerConvention::BAD)
 Compute Jacobian matrix between angular velocity in body coordinates and rate of change of angles.
 
EulerAnglesset (const OrthoMatrix3x3 &m, EulerConvention::Convention C=EulerConvention::BAD)
 
EulerAnglesset (const Quat &q, EulerConvention::Convention C=EulerConvention::BAD)
 Set the angles to correspond to quaternion q in given convention.
 
void set (const Vec3 &angles)
 Set the three angles in one call.
 
void set (Real x, Real y, Real z)
 Set the three angles in one call.
 
Realx ()
 Get or set the first angle.
 
Real x () const
 Get the first angle.
 
Realy ()
 Get or set the second angle.
 
Real y () const
 Get the second angle.
 
Realz ()
 Get or set the third angle.
 
Real z () const
 Get the third angle.
 

Static Public Member Functions

static EulerAngles random (const Vec3 &min=Vec3(Real(0.0)), const Vec3 &max=Vec3(2 *agx::PI), EulerConvention::Convention c=EulerConvention::DEFAULT_CONVENTION)
 Generate an EulerAngles object with random angles in every axis [ 0 - 2PI ].
 

Detailed Description

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

There are 24 distinct Euler angles conventions which can be used to parameterize \(SO(3)\). 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.

Definition at line 69 of file EulerAngles.h.

Constructor & Destructor Documentation

◆ EulerAngles() [1/9]

agx::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/9]

agx::EulerAngles::EulerAngles ( const EulerAngles e)
default

Convention is set to C and angles are set to 0.

Copy constructor

◆ EulerAngles() [3/9]

agx::EulerAngles::EulerAngles ( Real  a,
Real  b,
Real  c,
int  C 
)

Explicit constructor.

◆ EulerAngles() [4/9]

agx::EulerAngles::EulerAngles ( Real  a,
Real  b,
Real  c,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)

Explicit constructor.

◆ EulerAngles() [5/9]

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

Explicit constructor.

◆ EulerAngles() [6/9]

template<typename T >
agx::EulerAngles::EulerAngles ( const Matrix4x4T< T > &  m,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)
explicit

Construct from 4x4 matrix in given convention.

◆ EulerAngles() [7/9]

template<typename T >
agx::EulerAngles::EulerAngles ( const Matrix3x3T< T > &  m,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)
explicit

Construct from 3x3 Matrix in given convention.

◆ EulerAngles() [8/9]

agx::EulerAngles::EulerAngles ( const OrthoMatrix3x3 m,
EulerConvention::Convention  C = EulerConvention::DEFAULT_CONVENTION 
)
explicit

◆ EulerAngles() [9/9]

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

Construct from quaternion in given convention.

Member Function Documentation

◆ get() [1/4]

template<typename T >
bool agx::EulerAngles::get ( Matrix3x3T< T > &  m) const

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

Returns
true if the conversion was successful

◆ get() [2/4]

template<typename T >
bool agx::EulerAngles::get ( Matrix4x4T< T > &  m) const

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

Returns
true if the conversion was successful

◆ get() [3/4]

bool agx::EulerAngles::get ( OrthoMatrix3x3 m) const

◆ get() [4/4]

bool agx::EulerAngles::get ( Quat q) const

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

Returns
true if the conversion was successful

◆ getOrder() [1/2]

EulerAngles::EulerOrder & agx::EulerAngles::getOrder ( )
inline

Get the convention.

Definition at line 362 of file EulerAngles.h.

◆ getOrder() [2/2]

const EulerAngles::EulerOrder & agx::EulerAngles::getOrder ( ) const
inline

Get or set the convention.

Definition at line 367 of file EulerAngles.h.

◆ operator=()

EulerAngles & agx::EulerAngles::operator= ( const EulerAngles e)
default

Assignment operator.

◆ operator[]() [1/2]

Real & agx::EulerAngles::operator[] ( size_t  i)
inline

Get an element by index as a reference.

Definition at line 351 of file EulerAngles.h.

◆ operator[]() [2/2]

Real agx::EulerAngles::operator[] ( size_t  i) const
inline

Get an element by index.

Definition at line 356 of file EulerAngles.h.

◆ ptr() [1/2]

Real * agx::EulerAngles::ptr ( )
Returns
a pointer to the data

Definition at line 394 of file EulerAngles.h.

◆ ptr() [2/2]

const Real * agx::EulerAngles::ptr ( ) const
Returns
a const pointer to the data

Definition at line 399 of file EulerAngles.h.

◆ random()

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

Generate an EulerAngles object with random angles in every axis [ 0 - 2PI ].

◆ set() [1/6]

template<typename T >
EulerAngles & agx::EulerAngles::set ( const Matrix3x3T< T > &  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.

Returns
a reference to this EulerAngles

◆ set() [2/6]

template<typename T >
EulerAngles & agx::EulerAngles::set ( const Matrix4x4T< T > &  m,
EulerConvention::Convention  c = EulerConvention::BAD 
)

Compute Jacobian matrix between angular velocity in body coordinates and rate of change of angles.

Compute Jacobian matrix between angular velocity in world coordinates and rate of change of angles. 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.

Returns
a reference to this EulerAngles

◆ set() [3/6]

EulerAngles & agx::EulerAngles::set ( const OrthoMatrix3x3 m,
EulerConvention::Convention  C = EulerConvention::BAD 
)

◆ set() [4/6]

EulerAngles & agx::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.

Returns
a reference to this EulerAngles

◆ set() [5/6]

void agx::EulerAngles::set ( const Vec3 angles)
inline

Set the three angles in one call.

Parameters
angles- Angles specified in radians.

Definition at line 373 of file EulerAngles.h.

◆ set() [6/6]

void agx::EulerAngles::set ( Real  x,
Real  y,
Real  z 
)
inline

Set the three angles in one call.

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

Definition at line 380 of file EulerAngles.h.

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

◆ x() [1/2]

Real & agx::EulerAngles::x ( )
inline

Get or set the first angle.

Definition at line 326 of file EulerAngles.h.

◆ x() [2/2]

Real agx::EulerAngles::x ( ) const
inline

Get the first angle.

Definition at line 321 of file EulerAngles.h.

Referenced by set().

◆ y() [1/2]

Real & agx::EulerAngles::y ( )
inline

Get or set the second angle.

Definition at line 336 of file EulerAngles.h.

◆ y() [2/2]

Real agx::EulerAngles::y ( ) const
inline

Get the second angle.

Definition at line 331 of file EulerAngles.h.

Referenced by set().

◆ z() [1/2]

Real & agx::EulerAngles::z ( )
inline

Get or set the third angle.

Definition at line 346 of file EulerAngles.h.

◆ z() [2/2]

Real agx::EulerAngles::z ( ) const
inline

Get the third angle.

Definition at line 341 of file EulerAngles.h.

Referenced by set().


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