Cafu Engine
cf::math::AnglesT< T > Class Template Reference

This class represents a triple of angles. More...

#include "Angles.hpp"

Inheritance diagram for cf::math::AnglesT< T >:

Public Member Functions

 AnglesT ()
 The default constructor. It initializes all angles to zero. More...
 
 AnglesT (T x_, T y_, T z_)
 This constructor initializes the angles from x_, y_ and z_ respectively. More...
 
 AnglesT (const Vector3T< T > &v)
 A constructor for initializing an Angles instance from a Vector3T. More...
 
 AnglesT (const Matrix3x3T< T > &M)
 Constructs a set of angles that describe the same orientation as the given matrix. More...
 
 AnglesT (const QuaternionT< T > &Quat)
 Constructs a set of angles that describe the same orientation as the given quaternion. More...
 
T & pitch ()
 Provides the alias for the angle of rotation around the x-axis. TODO: The impl. should actually use y, not x here! More...
 
const T & pitch () const
 Provides the alias for the angle of rotation around the x-axis. More...
 
T & roll ()
 Provides the alias for the angle of rotation around the y-axis. TODO: The impl. should actually use x, not y here! More...
 
const T & roll () const
 Provides the alias for the angle of rotation around the y-axis. More...
 
T & yaw ()
 Provides the alias for the angle of rotation around the z-axis. More...
 
const T & yaw () const
 Provides the alias for the angle of rotation around the z-axis. More...
 
- Public Member Functions inherited from Vector3T< T >
 Vector3T ()
 The default constructor. It initializes all components to zero. More...
 
 Vector3T (T x_, T y_, T z_)
 This constructor initializes the components from x_, y_ and z_ respectively. More...
 
template<class C >
 Vector3T (const C Values[])
 This constructor initializes the components from an array of (at least) three Ts. More...
 
bool IsValid () const
 Returns true if the vector is valid, that is, all components are non-NANs. More...
 
T & operator[] (unsigned int Index)
 Component access by index number (0 to 2) rather than by name. More...
 
const T & operator[] (unsigned int Index) const
 Component access by index number (0 to 2) rather than by name. More...
 
Vector3T< float > AsVectorOfFloat () const
 Gets this Vector3T<T> as a Vector3T<float>, so that the cast is explicitly visible in user code. More...
 
Vector3T< double > AsVectorOfDouble () const
 Gets this Vector3T<T> as a Vector3T<double>, so that the cast is explicitly visible in user code. More...
 
Vector3T< int > AsVectorOfInt () const
 Gets this Vector3T<T> as a Vector3T<int>, so that the cast is explicitly visible in user code. More...
 
GetLengthSqr () const
 Returns the square of the length of this vector. More...
 
bool IsEqual (const Vector3T< T > &B, const T Epsilon) const
 Returns whether this vector is equal to B within tolerance Epsilon, that is, whether it is geometrically closer to B than Epsilon. More...
 
Vector3T< T > GetScaled (const T s) const
 Returns a copy of this vector scaled by s, that is, the scalar product (Skalarmultiplikation) of this vector and s. More...
 
Vector3T< T > GetScaled (const Vector3T< T > &S) const
 Returns a copy of this vector non-uniformely scaled by S. More...
 
Vector3T< T > GetRotX (const T Angle) const
 Returns a copy of this vector rotated around the x-axis by Angle degrees. More...
 
Vector3T< T > GetRotY (const T Angle) const
 Returns a copy of this vector rotated around the y-axis by Angle degrees. More...
 
Vector3T< T > GetRotZ (const T Angle) const
 Returns a copy of this vector rotated around the z-axis by Angle degrees. More...
 
void CreateOrthoVectors (Vector3T< T > &Left, Vector3T< T > &Down) const
 Returns two vectors that are orthogonal to this vector and to each other. More...
 
bool operator== (const Vector3T< T > &B) const
 Returns whether this vector and B are truly (bit-wise) identical. More...
 
bool operator!= (const Vector3T< T > &B) const
 Returns whether this vector and B are not equal (bit-wise). More...
 
Vector3T< T > operator+ (const Vector3T< T > &B) const
 Returns the sum of this Vector3T<T> and B. More...
 
Vector3T< T > operator- (const Vector3T< T > &B) const
 Returns the difference between this Vector3T<T> and B. More...
 
Vector3T< T > operator- () const
 The unary minus operator. B=-A is quasi identical with B=A.GetScaled(-1). More...
 
Vector3T< T > operator* (const T s) const
 Returns a copy of this vector scaled by s, that is, the scalar product (Skalarmultiplikation) of this vector and s. More...
 
Vector3T< T > operator/ (const T s) const
 Returns a copy of this vector divided by s, that is, the scalar product (Skalarmultiplikation) of this vector and 1/s. More...
 
dot (const Vector3T< T > &B) const
 Returns the dot product (Skalarprodukt) of this vector and B. More...
 
Vector3T< T > cross (const Vector3T< T > &B) const
 Returns the cross product (Vektorprodukt) of this vector and B. More...
 
Vector3T< T > & operator+= (const Vector3T< T > &B)
 Adds B to this vector. More...
 
Vector3T< T > & operator-= (const Vector3T< T > &B)
 Subtracts B from this vector. More...
 
Vector3T< T > & operator*= (const T s)
 Scales this vector by s. More...
 
Vector3T< T > & operator/= (const T s)
 Divides this vector by s. Assumes that s is not 0. More...
 

Static Public Member Functions

static T RadToDeg (const T Angle)
 Converts the given angle from radians to degrees. More...
 
static T DegToRad (const T Angle)
 Converts the given angle from degrees to radians. More...
 

Static Public Attributes

static const double PI
 This is PI. More...
 

Additional Inherited Members

- Public Attributes inherited from Vector3T< T >
x
 The x-component of this vector. More...
 
y
 The y-component of this vector. More...
 
z
 The z-component of this vector. More...
 

Detailed Description

template<class T>
class cf::math::AnglesT< T >

This class represents a triple of angles.

The class keeps the angles in degrees, not in radians.

The angles are typically used to describe an orientation. Generally, the orientation is achieved by composing three elemental rotations about the principal axes by the given angles. For this purpose, all related code in Cafu (e.g. the matrix and quaternion classes) uses the following conventions:

  • As everywhere in Cafu, a right-handed coordinate system is used: In world space, the x-axis points right, the y-axis points forward, and the z-axis points up. However, note that our entities and cameras, as detailed below, "look along" their x-axis, so that for them, the x-axis points forward, the y-axis points left, and the z-axis points up. It is this orientation that the following definitions of angles refer to.
  • The rotations are done
    • first about the z-axis (by the "heading" or "yaw" angle),
    • then about the rotated y-axis (by the "pitch" angle),
    • then about the rotated x-axis (by the "bank" or "roll" angle). This order is explained in greater detail in the references listed below.
  • Positive angles rotate counter-clockwise (the "right-hand rule").
  • North is along the x-axis, West is along the y-axis. This does not follow the compase-rose analogy (that we had normally preferred), where North is along the y-axis, East is along the x-axis, and positive rotation is clockwise, but was accepted for conformance with the broader conventions (e.g. DIN 9300) given in the references below.

References (in German, as the English editions don't have the relevant math):

  • http://de.wikipedia.org/wiki/Eulersche_Winkel Especially section "z, y', x''-Konvention in der Fahrzeugtechnik" has a very well explained derivation of a rotation matrix from Euler angles. Note, however, that the resulting matrix transforms from world-to-model space, whereas we're more interested in the transpose, in order to transform from model-to-world space.
  • http://de.wikipedia.org/wiki/Roll-Nick-Gier-Winkel Section "Z, Y', X'' Konvention" complements the above, where the model-to-world space matrix is readily given, and the math for converting back to Euler angles as well.

Constructor & Destructor Documentation

template<class T>
cf::math::AnglesT< T >::AnglesT ( )
inline

The default constructor. It initializes all angles to zero.

template<class T>
cf::math::AnglesT< T >::AnglesT ( x_,
y_,
z_ 
)
inline

This constructor initializes the angles from x_, y_ and z_ respectively.

template<class T>
cf::math::AnglesT< T >::AnglesT ( const Vector3T< T > &  v)
inline

A constructor for initializing an Angles instance from a Vector3T.

template<class T>
AnglesT::AnglesT ( const Matrix3x3T< T > &  M)

Constructs a set of angles that describe the same orientation as the given matrix.

template<class T>
AnglesT::AnglesT ( const QuaternionT< T > &  Quat)

Constructs a set of angles that describe the same orientation as the given quaternion.

Member Function Documentation

template<class T>
static T cf::math::AnglesT< T >::DegToRad ( const T  Angle)
inlinestatic

Converts the given angle from degrees to radians.

template<class T>
T& cf::math::AnglesT< T >::pitch ( )
inline

Provides the alias for the angle of rotation around the x-axis. TODO: The impl. should actually use y, not x here!

template<class T>
const T& cf::math::AnglesT< T >::pitch ( ) const
inline

Provides the alias for the angle of rotation around the x-axis.

template<class T>
static T cf::math::AnglesT< T >::RadToDeg ( const T  Angle)
inlinestatic

Converts the given angle from radians to degrees.

template<class T>
T& cf::math::AnglesT< T >::roll ( )
inline

Provides the alias for the angle of rotation around the y-axis. TODO: The impl. should actually use x, not y here!

template<class T>
const T& cf::math::AnglesT< T >::roll ( ) const
inline

Provides the alias for the angle of rotation around the y-axis.

template<class T>
T& cf::math::AnglesT< T >::yaw ( )
inline

Provides the alias for the angle of rotation around the z-axis.

template<class T>
const T& cf::math::AnglesT< T >::yaw ( ) const
inline

Provides the alias for the angle of rotation around the z-axis.

Member Data Documentation

template<class T>
const double cf::math::AnglesT< T >::PI
static

This is PI.


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