All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
blaze::RotationMatrix< typename > Class Template Reference

Efficient, generic implementation of a 3x3 rotation matrix.The RotationMatrix class is the representation of a 3x3 rotation matrix with a total of 9 statically allocated elements of arbitrary type. The naming convention of the elements is as following: More...

#include <RotationMatrix.h>

Inherits blaze::DenseMatrix< RotationMatrix< Type >, false >.

Public Types

typedef RotationMatrix< Type > This
 Type of this RotationMatrix instance.
 
typedef This ResultType
 Result type for expression template evaluations.
 
typedef Type ElementType
 Type of the matrix elements.
 
typedef const RotationMatrixCompositeType
 Data type for composite expression templates.
 
typedef MT MatrixType
 Type of the matrix.
 

Public Member Functions

template<typename Other >
RotationMatrix< Type > & operator= (const RotationMatrix< Other > &rhs)
 Assignment operator for different RotationMatrix instances. More...
 
template<typename Other >
RotationMatrix< Type > & operator*= (const RotationMatrix< Other > &rhs)
 Multiplication assignment operator for the multiplication between two rotation matrices ( $ A*=B $). More...
 
BLAZE_ALWAYS_INLINE MatrixTypeoperator~ ()
 Conversion operator for non-constant matrices. More...
 
BLAZE_ALWAYS_INLINE const
MatrixType
operator~ () const
 Conversion operator for constant matrices. More...
 
Operators
RotationMatrixoperator= (const RotationMatrix &rhs)
 Copy assignment operator for RotationMatrix. More...
 
template<typename Other >
RotationMatrixoperator= (const RotationMatrix< Other > &rhs)
 
Type operator[] (size_t index) const
 1D-access to the rotation matrix elements. More...
 
Type operator() (size_t i, size_t j) const
 2D-access to the rotation matrix elements. More...
 
template<typename Other >
RotationMatrixoperator*= (const RotationMatrix< Other > &rhs)
 
Utility functions
size_t rows () const
 Returns the current number of rows of the rotation matrix. More...
 
size_t columns () const
 Returns the current number of columns of the rotation matrix. More...
 
void reset ()
 Reset to the default initial values. More...
 
Type getDeterminant () const
 Calculation of the determinant of the rotation matrix. More...
 
RotationMatrixtranspose ()
 Transposing the rotation matrix. More...
 
RotationMatrixinvert ()
 Inverting the matrix. More...
 
void swap (RotationMatrix &m)
 Swapping the contents of two 3x3 matrices. More...
 
Expression template evaluation functions
template<typename Other >
bool isAliased (const Other *alias) const
 Returns whether the rotation matrix is aliased with the given address alias. More...
 
Math functions
template<typename Other >
const StaticMatrix< typename
MultTrait< Type, Other >::Type, 3UL, 3UL, false > 
rotate (const StaticMatrix< Other, 3UL, 3UL, false > &m) const
 Rotation of a matrix M ( $ ROT=R*M*R^{-1} $). More...
 
template<typename Other >
const StaticMatrix< typename
MultTrait< Type, Other >::Type, 3UL, 3UL, false > 
diagRotate (const StaticMatrix< Other, 3UL, 3UL, false > &m) const
 Rotation of a diagonal matrix M ( $ ROT=R*M*R^{-1} $). More...
 
Euler rotations

For the classification of the Euler rotation, the following characteristics are defined:

  • Inner axis: the inner axis is the axis of the first rotation matrix multiplied to a vector.
  • Parity: the parity is even, if the inner axis X is followed by the middle axis Y, or Y is followed by Z, or Z is followed by X; otherwise parity is odd.
  • Repetition: repetition tells, if the first and last axes are the same or different.
  • Frame: the frame refers to the frame from which the Euler angles are calculated.

Altogether, there are 24 possible Euler rotations. The possibilities are consisting of the choice of the inner axis (X,Y or Z), the parity (even or odd), repetition (yes or no) and the frame (static or rotating). E.g., an Euler order of XYZs stands for the rotation order of x-, y- and z-axis in a static frame (inner axis: X, parity: even, repetition: no, frame: static), whereas YXYr stands for the rotation order y-, x- and y-axis in a rotating frame ( inner axis: Y, parity: odd, repetition: yes, frame: rotating).

const StaticVector< Type, 3UL > getEulerAnglesXYZ () const
 Calculation of the Euler angles (in radian measure). More...
 
const StaticVector< Type, 3UL > getEulerAngles (EulerRotation order) const
 Calculation of the Euler angles for a specific rotation order. More...
 

Private Attributes

Member variables
Type v_ [9]
 The nine statically allocated matrix elements. More...
 

Constructors

 RotationMatrix ()
 The default constructor for RotationMatrix. More...
 
template<typename Axis >
 RotationMatrix (StaticVector< Axis, 3UL > axis, Type angle)
 Rotation matrix constructor. More...
 
 RotationMatrix (const RotationMatrix &m)
 The copy constructor for RotationMatrix. More...
 
template<typename Other >
 RotationMatrix (const RotationMatrix< Other > &m)
 Conversion constructor from different RotationMatrix instances. More...
 
 RotationMatrix (Type xx, Type xy, Type xz, Type yx, Type yy, Type yz, Type zx, Type zy, Type zz)
 Constructor for a direct initialization of all rotation matrix elements. More...
 

Detailed Description

template<typename>
class blaze::RotationMatrix< typename >

Efficient, generic implementation of a 3x3 rotation matrix.

The RotationMatrix class is the representation of a 3x3 rotation matrix with a total of 9 statically allocated elements of arbitrary type. The naming convention of the elements is as following:

\[\left(\begin{array}{*{3}{c}} xx & xy & xz \\ yx & yy & yz \\ zx & zy & zz \\ \end{array}\right)\]


These elements can be accessed directly with the 1D subscript operator or with the 2D function operator. The numbering of the matrix elements is

\[\left(\begin{array}{*{3}{c}} 0 & 1 & 2 \\ 3 & 4 & 5 \\ 6 & 7 & 8 \\ \end{array}\right)\]

Note: The RotationMatrix class can only be instantiated for non-cv-qualified floating point types! Therefore the only possible RotationMatrix instantiations are

The attempt to create a rotation matrix with an integral data type results in a compile time error.

Constructor & Destructor Documentation

template<typename Type >
blaze::RotationMatrix< Type >::RotationMatrix ( )
inlineexplicit

The default constructor for RotationMatrix.

The diagonal matrix elements are initialized with 1, all other elements are initialized with 0.

template<typename Type >
template<typename Axis >
blaze::RotationMatrix< Type >::RotationMatrix ( StaticVector< Axis, 3UL >  axis,
Type  angle 
)
explicit

Rotation matrix constructor.

Parameters
axisThe rotation axis.
angleThe rotation angle (radian measure).

This constructor creates a rotation matrix from the rotation axis axis and the rotation angle angle. axis may be an arbitrary, non-zero vector of any length. However, it is allowed to use the zero vector (0,0,0) in combination with an angle of 0. This combination results in the default rotation matrix

\[\left(\begin{array}{*{3}{c}} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array}\right)\]

template<typename Type >
blaze::RotationMatrix< Type >::RotationMatrix ( const RotationMatrix< typename > &  m)
inline

The copy constructor for RotationMatrix.

Parameters
mRotation matrix to be copied.

The copy constructor is explicitly defined in order to enable/facilitate NRV optimization.

template<typename Type >
template<typename Other >
blaze::RotationMatrix< Type >::RotationMatrix ( const RotationMatrix< Other > &  m)
inline

Conversion constructor from different RotationMatrix instances.

Parameters
mRotation matrix to be copied.
template<typename Type >
blaze::RotationMatrix< Type >::RotationMatrix ( Type  xx,
Type  xy,
Type  xz,
Type  yx,
Type  yy,
Type  yz,
Type  zx,
Type  zy,
Type  zz 
)
inlineexplicitprivate

Constructor for a direct initialization of all rotation matrix elements.

Parameters
xxThe initial value for the xx-component.
xyThe initial value for the xy-component.
xzThe initial value for the xz-component.
yxThe initial value for the yx-component.
yyThe initial value for the yy-component.
yzThe initial value for the yz-component.
zxThe initial value for the zx-component.
zyThe initial value for the zy-component.
zzThe initial value for the zz-component.

Member Function Documentation

template<typename Type >
size_t blaze::RotationMatrix< Type >::columns ( ) const
inline

Returns the current number of columns of the rotation matrix.

Returns
The number of columns of the rotation matrix.
template<typename Type >
template<typename Other >
const StaticMatrix< typename MultTrait< Type, Other >::Type, 3UL, 3UL, false > blaze::RotationMatrix< Type >::diagRotate ( const StaticMatrix< Other, 3UL, 3UL, false > &  m) const
inline

Rotation of a diagonal matrix M ( $ ROT=R*M*R^{-1} $).

Parameters
mThe diagonal matrix to be rotated.
Returns
The rotated matrix.

The DiagRotate function is a special case of the rotate function. The matrix is assumed to be a diagonal matrix, which reduces the number of floating point operations of the rotation. The function is selected for matrices of different data type (in case Type and Other are supported by the MultTrait class). The function returns a matrix of the higher-order data type of the two involved data types.

Note: This function is only defined for matrices of floating point type. The attempt to use this function with matrices of integral data type will result in a compile time error.

template<typename Type >
Type blaze::RotationMatrix< Type >::getDeterminant ( ) const
inline

Calculation of the determinant of the rotation matrix.

Returns
The determinant of the rotation matrix.
template<typename Type >
const StaticVector< Type, 3UL > blaze::RotationMatrix< Type >::getEulerAngles ( EulerRotation  order) const

Calculation of the Euler angles for a specific rotation order.

Parameters
orderThe specific rotation order.
Returns
The specific Euler angles (radian measure).
template<typename Type >
const StaticVector< Type, 3UL > blaze::RotationMatrix< Type >::getEulerAnglesXYZ ( ) const
inline

Calculation of the Euler angles (in radian measure).

Returns
The Euler angles for a rotation order of x, y, z (radian measure).

The Euler angles are calculated for a rotation order of x-, y- and z-axis.

template<typename Type >
RotationMatrix< Type > & blaze::RotationMatrix< Type >::invert ( )
inline

Inverting the matrix.

Returns
Reference to the inverted matrix.

This function has the same effect as the transpose() function ( $ R^-1 = R^T $).

template<typename Type >
template<typename Other >
bool blaze::RotationMatrix< Type >::isAliased ( const Other *  alias) const
inline

Returns whether the rotation matrix is aliased with the given address alias.

Parameters
aliasThe alias to be checked.
Returns
true in case the alias corresponds to this matrix, false if not.
template<typename Type >
Type blaze::RotationMatrix< Type >::operator() ( size_t  i,
size_t  j 
) const
inline

2D-access to the rotation matrix elements.

Parameters
iAccess index for the row. The index has to be in the range [0..2].
jAccess index for the column. The index has to be in the range [0..2].
Returns
Copy of the accessed element.
template<typename >
template<typename Other >
RotationMatrix<Type>& blaze::RotationMatrix< typename >::operator*= ( const RotationMatrix< Other > &  rhs)
inline

Multiplication assignment operator for the multiplication between two rotation matrices ( $ A*=B $).

Parameters
rhsThe right-hand side rotation matrix for the multiplication.
Returns
Reference to the rotation matrix.
template<typename Type >
RotationMatrix< Type > & blaze::RotationMatrix< Type >::operator= ( const RotationMatrix< typename > &  rhs)
inline

Copy assignment operator for RotationMatrix.

Parameters
rhsRotation matrix to be copied.
Returns
Reference to the assigned rotation matrix.

Explicit definition of a copy assignment operator for performance reasons.

template<typename >
template<typename Other >
RotationMatrix<Type>& blaze::RotationMatrix< typename >::operator= ( const RotationMatrix< Other > &  rhs)
inline

Assignment operator for different RotationMatrix instances.

Parameters
rhsRotation matrix to be copied.
Returns
Reference to the assigned rotation matrix.
template<typename Type >
Type blaze::RotationMatrix< Type >::operator[] ( size_t  index) const
inline

1D-access to the rotation matrix elements.

Parameters
indexAccess index. The index has to be in the range $[0..8]$.
Returns
Copy of the accessed element.

In case BLAZE_USER_ASSERT() is active, this operator performs an index check.

template<typename , bool >
BLAZE_ALWAYS_INLINE MatrixType& blaze::Matrix< typename, bool >::operator~ ( )
inlineinherited

Conversion operator for non-constant matrices.

Returns
Reference of the actual type of the matrix.
template<typename , bool >
BLAZE_ALWAYS_INLINE const MatrixType& blaze::Matrix< typename, bool >::operator~ ( ) const
inlineinherited

Conversion operator for constant matrices.

Returns
Constant reference of the actual type of the matrix.
template<typename Type >
void blaze::RotationMatrix< Type >::reset ( )
inline

Reset to the default initial values.

Returns
void

This function resets the rotation matrix to the default initial values:

\[\left(\begin{array}{*{3}{c}} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array}\right)\]

template<typename Type >
template<typename Other >
const StaticMatrix< typename MultTrait< Type, Other >::Type, 3UL, 3UL, false > blaze::RotationMatrix< Type >::rotate ( const StaticMatrix< Other, 3UL, 3UL, false > &  m) const
inline

Rotation of a matrix M ( $ ROT=R*M*R^{-1} $).

Parameters
mThe matrix to be rotated.
Returns
The rotated matrix.

The function is selected for matrices of different data type (in case Type and Other are supported by the MultTrait class). The function returns a matrix of the higher-order data type of the two involved data types.

Note: This function is only defined for matrices of floating point type. The attempt to use this function with matrices of integral data type will result in a compile time error.

template<typename Type >
size_t blaze::RotationMatrix< Type >::rows ( ) const
inline

Returns the current number of rows of the rotation matrix.

Returns
The number of rows of the rotation matrix.
template<typename Type >
void blaze::RotationMatrix< Type >::swap ( RotationMatrix< typename > &  m)
inline

Swapping the contents of two 3x3 matrices.

Parameters
mThe matrix to be swapped.
Returns
void
Exceptions
no-throwguarantee.
template<typename Type >
RotationMatrix< Type > & blaze::RotationMatrix< Type >::transpose ( )
inline

Transposing the rotation matrix.

Returns
Reference to the transposed rotation matrix.

This function has the same effect as the invert() function ( $ R^T = R^-1 $).

Member Data Documentation

template<typename >
Type blaze::RotationMatrix< typename >::v_[9]
private

The nine statically allocated matrix elements.

Access to the matrix elements is gained via the subscript or function call operator. The order of the elements is

\[\left(\begin{array}{*{3}{c}} 0 & 1 & 2 \\ 3 & 4 & 5 \\ 6 & 7 & 8 \\ \end{array}\right)\]


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