Rosetta Utilities  2015.09
Public Member Functions | Static Public Member Functions | Private Types | List of all members
numeric::EulerAngles< typename > Class Template Reference

Euler angles 3-D orientation representation. More...

#include <EulerAngles.hh>

Public Member Functions

 EulerAngles ()
 Default constructor. More...
 
 EulerAngles (xyzVector< T > const &v)
 Copy constructor. More...
 
 EulerAngles (Value const &phi, Value const &psi, Value const &theta)
 Triple value constructor. More...
 
 EulerAngles (xyzMatrix< T > rotation_matrix)
 Construct from rotation matrix. More...
 
 ~EulerAngles ()
 Destructor. More...
 
void from_rotation_matrix (xyzMatrix< T > matrix)
 
xyzMatrix< T > to_rotation_matrix ()
 Construct rotation matrix from three euler angles that describe the frame. See the description for from_rotation_matrix to understand the Z-X-Z transformation convention. More...
 
Valuephi ()
 Value phi in radians. More...
 
void phi (Value const &value)
 Set value phi in radians. More...
 
Valuephi_radians ()
 Value phi in radians. More...
 
void phi_radians (Value const &value)
 Set value phi in radians. More...
 
Value phi_degrees ()
 Value phi in degrees. More...
 
void phi_degrees (Value const &value)
 Set value phi in degrees. More...
 
Valuepsi ()
 Value psi in radians. More...
 
void psi (Value const &value)
 Set value psi in radians. More...
 
Valuepsi_radians ()
 Value psi in radians. More...
 
void psi_radians (Value const &value)
 Set value psi in radians. More...
 
Value psi_degrees ()
 Value psi in degrees. More...
 
void psi_degrees (Value const &value)
 Set value psi in degrees. More...
 
Valuetheta ()
 Value theta in radians. More...
 
void theta (Value const &value)
 Set value theta in radians. More...
 
Valuetheta_radians ()
 Value theta in radians. More...
 
void theta_radians (Value const &value)
 Set value theta in radians. More...
 
Value theta_degrees ()
 Value theta in degrees. More...
 
void theta_degrees (Value const &value)
 Set value theta in degrees. More...
 
- Public Member Functions inherited from numeric::xyzVector< T >
 xyzVector ()
 Default constructor. More...
 
 xyzVector (xyzVector const &v)
 Copy constructor. More...
 
 xyzVector (xyzVector< U > const &v)
 Copy constructor. More...
 
 xyzVector (Value const &t)
 Uniform value constructor. More...
 
 xyzVector (Value const &x_a, Value const &y_a, Value const &z_a)
 Triple value constructor. More...
 
 xyzVector (U const *p)
 Pointer to contiguous values constructor. More...
 
 ~xyzVector ()
 Destructor. More...
 
xyzVectoroperator= (xyzVector const &v)
 Copy assignment. More...
 
xyzVectoroperator= (xyzVector< U > const &v)
 Copy assignment. More...
 
xyzVectoroperator= (U const *p)
 Assignment from pointer to contiguous values. More...
 
xyzVectoroperator= (Value const &t)
 = Value More...
 
xyzVectoroperator+= (xyzVector< U > const &v)
 += xyzVector More...
 
xyzVectoroperator+= (Value const &t)
 += Value More...
 
xyzVectoroperator-= (xyzVector< U > const &v)
 -= xyzVector More...
 
xyzVectoroperator-= (Value const &t)
 -= Value More...
 
xyzVectorscaled_assign (Value const &t, xyzVector< U > const &v)
 Assign Value * xyzVector. More...
 
xyzVectorscaled_add (Value const &t, xyzVector< U > const &v)
 Add Value * xyzVector. More...
 
xyzVectorscaled_sub (Value const &t, xyzVector< U > const &v)
 Subtract Value * xyzVector. More...
 
xyzVectoroperator*= (Value const &t)
 *= Value More...
 
xyzVectoroperator/= (Value const &t)
 /= Value More...
 
xyzVectorassign (Value const &x_a, Value const &y_a, Value const &z_a)
 Triple value assignment. More...
 
std::string to_string () const
 to_string, useful for utility exits More...
 
void show (std::ostream &output=std::cout) const
 Show. More...
 
xyzVectorclear ()
 Clear. More...
 
xyzVectorzero ()
 Zero. More...
 
xyzVectornegate ()
 Negate. More...
 
xyzVector operator- () const
 -xyzVector (negated copy) More...
 
xyzVector negated () const
 Negated copy. More...
 
void negated (xyzVector &a) const
 Negated: Return via argument (slightly faster) More...
 
xyzVectormin (xyzVector const &v)
 Set minimum coordinates wrt another xyzVector. More...
 
xyzVectormax (xyzVector const &v)
 Set maximum coordinates wrt another xyzVector. More...
 
xyzVectornormalize ()
 Normalize. More...
 
xyzVectornormalize (Value const &length_a)
 Normalize to a length. More...
 
minimum_value () const
 get the lowest of the three values in the vector More...
 
maximum_value () const
 get the highest of the three values in the vector More...
 
void normalized (xyzVector &a) const
 Normalized. More...
 
void normalized (Value const &length_a, xyzVector &a) const
 Normalized to a length. More...
 
xyzVector normalized () const
 Normalized copy. More...
 
xyzVector normalized (Value const &length_a) const
 Normalized to a length copy. More...
 
xyzVectornormalize_or_zero ()
 Normalize: zero xyzVector if length is zero. More...
 
xyzVectornormalize_or_zero (Value const &length_a)
 Normalize to a length: zero xyzVector if length is zero. More...
 
void normalized_or_zero (xyzVector &a) const
 Normalized: zero xyzVector if length is zero. More...
 
void normalized_or_zero (Value const &length_a, xyzVector &a) const
 Normalized to a length: zero xyzVector if length is zero. More...
 
xyzVector normalized_or_zero () const
 Normalized copy: Zero xyzVector if length is zero. More...
 
xyzVector normalized_or_zero (Value const &length_a) const
 Normalized to a length copy: Zero xyzVector if length is zero. More...
 
xyzVectornormalize_any ()
 Normalize: arbitrary normalized xyzVector if length is zero. More...
 
xyzVectornormalize_any (Value const &length_a)
 Normalize to a length: arbitrary normalized xyzVector if length is zero. More...
 
void normalized_any (xyzVector &a) const
 Normalized: arbitrary normalized xyzVector if length is zero. More...
 
void normalized_any (Value const &length_a, xyzVector &a) const
 Normalized to a length: arbitrary normalized xyzVector if length is zero. More...
 
xyzVector normalized_any () const
 Normalized copy: Arbitrary normalized xyzVector if length is zero. More...
 
xyzVector normalized_any (Value const &length_a) const
 Normalized to a length copy: Arbitrary normalized xyzVector if length is zero. More...
 
xyzVectorproject_normal (xyzVector const &v)
 Project normal. More...
 
xyzVector projected_normal (xyzVector const &v) const
 Projected normal copy. More...
 
void projected_normal (xyzVector const &v, xyzVector &a) const
 Projected normal. More...
 
xyzVectorproject_parallel (xyzVector const &v)
 Project parallel. More...
 
xyzVector projected_parallel (xyzVector const &v) const
 Projected parallel copy. More...
 
void projected_parallel (xyzVector const &v, xyzVector &a)
 Projected parallel. More...
 
Value distance (xyzVector const &v) const
 Distance. More...
 
Value distance_squared (xyzVector const &v) const
 Distance. More...
 
Value dot (xyzVector const &v) const
 Distance squared. More...
 
Value dot_product (xyzVector const &v) const
 Dot product. More...
 
Value inner_product (xyzVector const &v) const
 Inner product ( == dot product ) More...
 
xyzVector cross (xyzVector const &v) const
 Cross product. More...
 
xyzVector cross_product (xyzVector const &v) const
 Cross product. More...
 
bool is_zero () const
 Is zero? More...
 
bool is_normalized () const
 Is exactly normalized? More...
 
bool is_normalized (Value const &tol) const
 Is normalized to within a tolerance? More...
 
bool is_unit () const
 Is exactly a unit vector? More...
 
bool is_unit (Value const &tol) const
 Is a unit vector to within a tolerance? More...
 
Value const & x () const
 Value x const. More...
 
Valuex ()
 Value x. More...
 
void x (Value const &x_a)
 x assignment More...
 
Value const & y () const
 Value y const. More...
 
Valuey ()
 Value y. More...
 
void y (Value const &y_a)
 y assignment More...
 
Value const & z () const
 Value z const. More...
 
Valuez ()
 Value z. More...
 
void z (Value const &z_a)
 z assignment More...
 
Value length () const
 Length. More...
 
Value length_squared () const
 Length squared. More...
 
Value norm () const
 Norm. More...
 
Value norm_squared () const
 Norm squared. More...
 
Value magnitude () const
 Magnitude. More...
 
Value magnitude_squared () const
 Magnitude squared. More...
 
Value const & at (int const i) const
 xyzVector.at: 0-based index with bounds checking More...
 
Valueat (int const i)
 xyzVector.at: 0-based index with bounds checking More...
 
Value const & operator[] (int const i) const
 xyzVector[ i ] const: 0-based index More...
 
Valueoperator[] (int const i)
 xyzVector[ i ]: 0-based index More...
 
Value const & operator() (int const i) const
 xyzVector( i ) const: 1-based index More...
 
Valueoperator() (int const i)
 xyzVector( i ): 1-based index More...
 
bool equal_length (xyzVector const &v)
 Equal length? More...
 
bool not_equal_length (xyzVector const &v)
 Not equal length? More...
 
bool longer (xyzVector const &v)
 Longer? More...
 
bool longer_or_equal (xyzVector const &v)
 Longer or equal length? More...
 
bool shorter (xyzVector const &v)
 Shorter? More...
 
bool shorter_or_equal (xyzVector const &v)
 Shorter or equal length? More...
 

Static Public Member Functions

static T angular_distance_between (EulerAngles< T > a1, EulerAngles< T > a2)
 Get angular distance between two sets of Euler Angles. More...
 
static EulerAngles< T > from_degrees (T phi, T psi, T theta)
 
static EulerAngles< T > from_degrees (xyzVector< T > vector)
 
static EulerAngles< T > from_radians (T phi, T psi, T theta)
 
static EulerAngles< T > from_radians (xyzVector< T > vector)
 

Private Types

typedef xyzVector< T > Vector
 
typedef xyzMatrix< T > Matrix
 
typedefValue
 

Additional Inherited Members

- Public Types inherited from numeric::xyzVector< T >
typedefValue
 
typedef T & Reference
 
typedef T const & ConstReference
 
typedef T * Pointer
 
typedef T const * ConstPointer
 
typedefvalue_type
 
typedef T & reference
 
typedef T const & const_reference
 
typedef T * pointer
 
typedef T const * const_pointer
 
typedef void iterator_category
 
typedef void difference_type
 

Detailed Description

template<typename>
class numeric::EulerAngles< typename >

Euler angles 3-D orientation representation.

Remarks
The three euler angles (in radians) that describing a rotation operation of a Z axis rotation by the angle phi (position 1), followed by an X axis rotation by the angle theta (position 3), followed by another Z axis rotation by the angle psi (position 2). this->code is a modified version of Alex Z's code from r++.

The range of phi is ( -pi, pi ]; The range of psi is ( -pi, pi ]; The range of theta is [ 0, pi ];

Member Typedef Documentation

template<typename >
typedef xyzMatrix<T> numeric::EulerAngles< typename >::Matrix
private
template<typename >
typedef T numeric::EulerAngles< typename >::Value
private
template<typename >
typedef xyzVector<T> numeric::EulerAngles< typename >::Vector
private

Constructor & Destructor Documentation

template<typename >
numeric::EulerAngles< typename >::EulerAngles ( )
inline

Default constructor.

Note
Values are initialized to zero
template<typename >
numeric::EulerAngles< typename >::EulerAngles ( xyzVector< T > const &  v)
inline

Copy constructor.

template<typename >
numeric::EulerAngles< typename >::EulerAngles ( Value const &  phi,
Value const &  psi,
Value const &  theta 
)
inline

Triple value constructor.

template<typename >
numeric::EulerAngles< typename >::EulerAngles ( xyzMatrix< T >  rotation_matrix)
inline

Construct from rotation matrix.

References numeric::EulerAngles< typename >::from_rotation_matrix().

template<typename >
numeric::EulerAngles< typename >::~EulerAngles ( )
inline

Destructor.

Member Function Documentation

template<typename >
static T numeric::EulerAngles< typename >::angular_distance_between ( EulerAngles< T >  a1,
EulerAngles< T >  a2 
)
inlinestatic

Get angular distance between two sets of Euler Angles.

References numeric::rotation_angle().

template<typename >
static EulerAngles<T> numeric::EulerAngles< typename >::from_degrees ( phi,
psi,
theta 
)
inlinestatic
template<typename >
static EulerAngles<T> numeric::EulerAngles< typename >::from_degrees ( xyzVector< T >  vector)
inlinestatic
template<typename >
static EulerAngles<T> numeric::EulerAngles< typename >::from_radians ( phi,
psi,
theta 
)
inlinestatic
template<typename >
static EulerAngles<T> numeric::EulerAngles< typename >::from_radians ( xyzVector< T >  vector)
inlinestatic
template<typename >
void numeric::EulerAngles< typename >::from_rotation_matrix ( xyzMatrix< T >  matrix)
inline

The equivalent rotation matrix representation of the euler angles would be:

FIGURE 1: R = [ cos(psi)cos(phi)-cos(theta)sin(phi)sin(psi) cos(psi)sin(phi)+cos(theta)cos(phi)sin(psi) sin(psi)sin(theta) -sin(psi)cos(phi)-cos(theta)sin(phi)cos(psi) -sin(psi)sin(phi)+cos(theta)cos(phi)cos(psi) cos(psi)sin(theta) sin(theta)sin(phi) -sin(theta)cos(phi) cos(theta) ]

The zz_ coordinate gives away theta. Theta may be computed as acos( zz_ ), or, as Alex does it, asin( sqrt( 1 - zz^2)) Since there is redundancy in theta, this->function chooses a theta with a positive sin(theta): i.e. quadrants I and II. Assuming we have a positive sin theta pushes phi and psi into conforming angles.

NOTE on theta: asin returns a value in the range [ -pi/2, pi/2 ], and we have artificially created a positive sin(theta), so we will get a asin( pos_sin_theta ), we have a value in the range [ 0, pi/2 ]. To convert this->into the actual angle theta, we examine the zz sign. If zz is negative, we chose the quadrant II theta. That is, asin( pos_sin_theta) returned an angle, call it theta'. Now, if cos( theta ) is negative, then we want to choose the positive x-axis rotation that's equivalent to -theta'. To do so, we reflect q through the y axis (See figure 2 below) to get p and then measure theta as pi - theta'.

FIGURE 2:

II | I | p. | .q (cos(-theta'), std::abs(sin(theta'))) . | .

theta'( . | . ) theta' = asin( std::abs(sin(theta))

| IV | The angle between the positive x axis and p is pi - theta'.

Since zx and zy contain only phi terms and a constant sin( theta ) term, phi is given by atan2( sin_phi, cos_phi ) = atan2( c*sin_phi, c*cos_phi ) = atan2( zx, -zy ) for c positive and non-zero. If sin_theta is zero, or very close to zero, we're at gimbal lock.

Moreover, since xz and yz contain only psi terms, psi may also be deduced using atan2.

There are 2 degenerate cases (gimbal lock)

  1. theta close to 0 (North Pole singularity), or
  2. theta close to pi (South Pole singularity) For these, we take: phi=acos(xx), theta = 0 (resp. Pi/2), psi = 0

References numeric::EulerAngles< typename >::phi(), numeric::constants::d::pi, numeric::EulerAngles< typename >::psi(), numeric::sin_cos_range(), basic::T(), numeric::EulerAngles< typename >::theta(), numeric::xyzMatrix< typename >::xx(), numeric::xyzMatrix< typename >::xz(), numeric::xyzMatrix< typename >::yz(), numeric::xyzMatrix< typename >::zx(), numeric::xyzMatrix< typename >::zy(), and numeric::xyzMatrix< typename >::zz().

Referenced by numeric::EulerAngles< typename >::EulerAngles().

template<typename >
Value& numeric::EulerAngles< typename >::phi ( )
inline
template<typename >
void numeric::EulerAngles< typename >::phi ( Value const &  value)
inline

Set value phi in radians.

References numeric::xyzVector< T >::x().

template<typename >
Value numeric::EulerAngles< typename >::phi_degrees ( )
inline
template<typename >
void numeric::EulerAngles< typename >::phi_degrees ( Value const &  value)
inline

Set value phi in degrees.

References numeric::constants::d::degrees_to_radians, and numeric::xyzVector< T >::x().

template<typename >
Value& numeric::EulerAngles< typename >::phi_radians ( )
inline

Value phi in radians.

References numeric::xyzVector< T >::x().

template<typename >
void numeric::EulerAngles< typename >::phi_radians ( Value const &  value)
inline

Set value phi in radians.

References numeric::xyzVector< T >::x().

template<typename >
Value& numeric::EulerAngles< typename >::psi ( )
inline
template<typename >
void numeric::EulerAngles< typename >::psi ( Value const &  value)
inline

Set value psi in radians.

References numeric::xyzVector< T >::y().

template<typename >
Value numeric::EulerAngles< typename >::psi_degrees ( )
inline
template<typename >
void numeric::EulerAngles< typename >::psi_degrees ( Value const &  value)
inline

Set value psi in degrees.

References numeric::constants::d::degrees_to_radians, and numeric::xyzVector< T >::y().

template<typename >
Value& numeric::EulerAngles< typename >::psi_radians ( )
inline

Value psi in radians.

References numeric::xyzVector< T >::y().

template<typename >
void numeric::EulerAngles< typename >::psi_radians ( Value const &  value)
inline

Set value psi in radians.

References numeric::xyzVector< T >::y().

template<typename >
Value& numeric::EulerAngles< typename >::theta ( )
inline
template<typename >
void numeric::EulerAngles< typename >::theta ( Value const &  value)
inline

Set value theta in radians.

References numeric::xyzVector< T >::z().

template<typename >
Value numeric::EulerAngles< typename >::theta_degrees ( )
inline
template<typename >
void numeric::EulerAngles< typename >::theta_degrees ( Value const &  value)
inline

Set value theta in degrees.

References numeric::constants::d::degrees_to_radians, and numeric::xyzVector< T >::z().

template<typename >
Value& numeric::EulerAngles< typename >::theta_radians ( )
inline

Value theta in radians.

References numeric::xyzVector< T >::z().

template<typename >
void numeric::EulerAngles< typename >::theta_radians ( Value const &  value)
inline

Set value theta in radians.

References numeric::xyzVector< T >::z().

template<typename >
xyzMatrix<T> numeric::EulerAngles< typename >::to_rotation_matrix ( )
inline

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