libalmath  2.5.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
AL::Math::Transform Struct Reference

A homogenous transformation matrix. More...

#include <altransform.h>

Public Member Functions

 Transform ()
 Create a Transform initialized to identity. More...
 
 Transform (const std::vector< float > &pFloats)
 Create a Transform with an std::vector. More...
 
 Transform (const float &pPosX, const float &pPosY, const float &pPosZ)
 Create a Transform initialized with explicit value for translation part. Rotation part is set to identity. More...
 
Transformoperator*= (const Transform &pT2)
 Overloading of operator *= for Transform. More...
 
Transform operator* (const Transform &pT2) const
 Overloading of operator * for Transform. More...
 
bool operator== (const Transform &pT2) const
 Overloading of operator == for Transform. More...
 
bool operator!= (const Transform &pT2) const
 Overloading of operator != for Transform. More...
 
bool isNear (const Transform &pT2, const float &pEpsilon=0.0001f) const
 Check if the actual Transform is near the one given in argument. More...
 
bool isTransform (const float &pEpsilon=0.0001f) const
 Check if the rotation part is correct. The condition checks are: $R^t * R = I$ and determinant(R) = 1.0 More...
 
void normalizeTransform (void)
 Normalize data, if needed, to have transform properties. More...
 
float norm () const
 Compute the norm translation part of the actual Transform: More...
 
float determinant () const
 Compute the determinant of rotation part of the actual Transform: More...
 
Transform inverse () const
 Compute the transform inverse of the actual Transform: More...
 
Transform diff (const Transform &pT2) const
 Compute the Transform between the actual Transform and the one given in argument: More...
 
float distanceSquared (const Transform &pT2) const
 Compute the squared distance between the actual Transform and the one given in argument (translation part): More...
 
float distance (const Transform &pT2) const
 Compute the distance between the actual Transform and the one given in argument: More...
 
void toVector (std::vector< float > &pReturnVector) const
 Return the Transform as a vector of float: More...
 
std::vector< float > toVector (void) const
 
void writeToVector (std::vector< float >::iterator &pIt) const
 Write the Transform in the vector and update the iterator: More...
 

Static Public Member Functions

static Transform fromRotX (const float pRotX)
 Create a Transform initialized with explicit rotation around x axis. More...
 
static Transform fromRotY (const float pRotY)
 Create a Transform initialized with explicit rotation around y axis. More...
 
static Transform fromRotZ (const float pRotZ)
 Create a Transform initialized with explicit rotation around z axis. More...
 
static Transform from3DRotation (const float &pWX, const float &pWY, const float &pWZ)
 Create a Transform initialize with euler angle. More...
 
static Transform fromPosition (const float pX, const float pY, const float pZ)
 Create a Transform initialize with explicit value for translation part. More...
 
static Transform fromPosition (const float &pX, const float &pY, const float &pZ, const float &pWX, const float &pWY, const float &pWZ)
 Create a Transform initialize with explicit value for translation part and euler angle. More...
 

Detailed Description

A homogenous transformation matrix.

more information

Definition at line 22 of file altransform.h.

Constructor & Destructor Documentation

AL::Math::Transform::Transform ( )

Create a Transform initialized to identity.

$ \left[\begin{array}{cccc} r_1c_1 & r_1c_2 & r_1c_3 & r_1c_4 \\ r_2c_1 & r_2c_2 & r_2c_3 & r_2c_4 \\ r_3c_1 & r_3c_2 & r_3c_3 & r_3c_4 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right] = \left[\begin{array}{cccc} 1.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 1.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 1.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

AL::Math::Transform::Transform ( const std::vector< float > &  pFloats)
explicit

Create a Transform with an std::vector.

Parameters
pFloatsAn std::vector<float> of size 12 or 16 for respectively:

$ \left[\begin{array}{cccc} r_1c_1 & r_1c_2 & r_1c_3 & r_1c_4 \\ r_2c_1 & r_2c_2 & r_2c_3 & r_2c_4 \\ r_3c_1 & r_3c_2 & r_3c_3 & r_3c_4 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right] = \left[\begin{array}{cccc} pFloats[00] & pFloats[01] & pFloats[02] & pFloats[03] \\ pFloats[04] & pFloats[05] & pFloats[06] & pFloats[07] \\ pFloats[08] & pFloats[09] & pFloats[10] & pFloats[11] \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

AL::Math::Transform::Transform ( const float &  pPosX,
const float &  pPosY,
const float &  pPosZ 
)

Create a Transform initialized with explicit value for translation part. Rotation part is set to identity.

$ \left[\begin{array}{cccc} r_1c_1 & r_1c_2 & r_1c_3 & r_1c_4 \\ r_2c_1 & r_2c_2 & r_2c_3 & r_2c_4 \\ r_3c_1 & r_3c_2 & r_3c_3 & r_3c_4 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right] = \left[\begin{array}{cccc} 1.0 & 0.0 & 0.0 & pPosX \\ 0.0 & 1.0 & 0.0 & pPosY \\ 0.0 & 0.0 & 1.0 & pPosZ \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

Parameters
pPosXthe float value for translation x
pPosYthe float value for translation y
pPosZthe float value for translation z

Member Function Documentation

float AL::Math::Transform::determinant ( ) const

Compute the determinant of rotation part of the actual Transform:

$pT.r_1c_1*pT.r_2c_2*pT.r_3c_3 + pT.r_1c_2*pT.r_2c_3*pT.r_3c_1 + pT.r_1c_3*pT.r_2c_1*pT.r_3c_2 - pT.r_1c_1*pT.r_2c_3*pT.r_3c_2 - pT.r_1c_2*pT.r_2c_1*pT.r_3c_3 - pT.r_1c_3*pT.r_2c_2*pT.r_3c_1$

Returns
the float determinant of rotation Transform part
Transform AL::Math::Transform::diff ( const Transform pT2) const

Compute the Transform between the actual Transform and the one given in argument:

result: inverse(pT1)*pT2

Parameters
pT2the second transform
float AL::Math::Transform::distance ( const Transform pT2) const

Compute the distance between the actual Transform and the one given in argument:

$\sqrt{(pT1.r_1c_4-pT2.r_1c_4)^2+(pT1.r_2c_4-pT2.r_2c_4)^2+(pT1.r_3c_4-pT2.r_3c_4)^2}$

Parameters
pT2the second Transform
Returns
the float distance between the two Transform
float AL::Math::Transform::distanceSquared ( const Transform pT2) const

Compute the squared distance between the actual Transform and the one given in argument (translation part):

$(pT1.r_1c_4-pT2.r_1c_4)^2+(pT1.r_2c_4-pT2.r_2c_4)^2+(pT1.r_3c_4-pT2.r_3c_4)^2$

Parameters
pT2the second Transform
Returns
the float squared distance between the two Transform: translation part
static Transform AL::Math::Transform::from3DRotation ( const float &  pWX,
const float &  pWY,
const float &  pWZ 
)
static

Create a Transform initialize with euler angle.

H = fromRotZ(pWZ)*fromRotY(pWY)*fromRotX(pWX)

Parameters
pWXthe float value for euler angle x in radian
pWYthe float value for euler angle y in radian
pWZthe float value for euler angle z in radian
static Transform AL::Math::Transform::fromPosition ( const float  pX,
const float  pY,
const float  pZ 
)
static

Create a Transform initialize with explicit value for translation part.

$ pT = \left[\begin{array}{cccc} 1.0 & 0.0 & 0.0 & pX \\ 0.0 & 1.0 & 0.0 & pY \\ 0.0 & 0.0 & 1.0 & pZ \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

Parameters
pXthe float value for translation axis x in meter (r1_c4)
pYthe float value for translation axis y in meter (r2_c4)
pZthe float value for translation axis z in meter (r3_c4)
static Transform AL::Math::Transform::fromPosition ( const float &  pX,
const float &  pY,
const float &  pZ,
const float &  pWX,
const float &  pWY,
const float &  pWZ 
)
static

Create a Transform initialize with explicit value for translation part and euler angle.

H = fromRotZ(pWZ)*fromRotY(pWY)*fromRotX(pWX)

then

H.r1_c4 = pX

H.r2_c4 = pY

H.r3_c4 = pZ

Parameters
pXthe float value for translation axis x in meter (r1_c4)
pYthe float value for translation axis y in meter (r2_c4)
pZthe float value for translation axis z in meter (r3_c4)
pWXthe float value for euler angle x in radian
pWYthe float value for euler angle y in radian
pWZthe float value for euler angle z in radian
static Transform AL::Math::Transform::fromRotX ( const float  pRotX)
static

Create a Transform initialized with explicit rotation around x axis.

$ pT = \left[\begin{array}{cccc} 1.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & cos(pRotX) & -sin(pRotX) & 0.0 \\ 0.0 & sin(pRotX) & cos(pRotX) & 0.0 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

Parameters
pRotXthe float value for angle rotation in radian around x axis
static Transform AL::Math::Transform::fromRotY ( const float  pRotY)
static

Create a Transform initialized with explicit rotation around y axis.

$ pT = \left[\begin{array}{cccc} cos(pRotY) & 0.0 & sin(pRotY) & 0.0 \\ 0.0 & 1.0 & 0.0 & 0.0 \\ -sin(pRotY) & 0.0 & cos(pRotY) & 0.0 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

Parameters
pRotYthe float value for angle rotation in radian around y axis
static Transform AL::Math::Transform::fromRotZ ( const float  pRotZ)
static

Create a Transform initialized with explicit rotation around z axis.

$ pT = \left[\begin{array}{cccc} cos(pRotZ) & -sin(pRotZ) & 0.0 & 0.0 \\ sin(pRotZ) & cos(pRotZ) & 0.0 & 0.0 \\ 0.0 & 0.0 & 1.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 1.0 \end{array}\right]$

Parameters
pRotZthe float value for angle rotation in radian around z axis
Transform AL::Math::Transform::inverse ( ) const

Compute the transform inverse of the actual Transform:

$ pT = \left[\begin{array}{cc}R & r \\ 0_{31} & 1 \end{array}\right]$ $ pTOut = \left[\begin{array}{cc} R^t & (-R^t*r) \\ 0_{31} & 1 \end{array}\right]$

Returns
the Transform inverse
bool AL::Math::Transform::isNear ( const Transform pT2,
const float &  pEpsilon = 0.0001f 
) const

Check if the actual Transform is near the one given in argument.

Parameters
pT2the second Transform
pEpsilonan optionnal epsilon distance: Default: 0.0001
Returns
true if the distance between the two Transform is less than pEpsilon
bool AL::Math::Transform::isTransform ( const float &  pEpsilon = 0.0001f) const

Check if the rotation part is correct. The condition checks are: $R^t * R = I$ and determinant(R) = 1.0

Parameters
pEpsilonan optionnal epsilon distance. Default: 0.0001
Returns
true if the Transform is correct
float AL::Math::Transform::norm ( ) const

Compute the norm translation part of the actual Transform:

$\sqrt{pT.r_1c_4^2+pT.r_2c_4^2+pT.r_3c_4^2}$

Returns
the float norm of the Transform
void AL::Math::Transform::normalizeTransform ( void  )

Normalize data, if needed, to have transform properties.

bool AL::Math::Transform::operator!= ( const Transform pT2) const

Overloading of operator != for Transform.

Parameters
pT2the second Transform
Transform AL::Math::Transform::operator* ( const Transform pT2) const

Overloading of operator * for Transform.

Parameters
pT2the second Transform
Transform& AL::Math::Transform::operator*= ( const Transform pT2)

Overloading of operator *= for Transform.

Parameters
pT2the second Transform
bool AL::Math::Transform::operator== ( const Transform pT2) const

Overloading of operator == for Transform.

Parameters
pT2the second Transform
void AL::Math::Transform::toVector ( std::vector< float > &  pReturnVector) const

Return the Transform as a vector of float:

$ \begin{array}{cccc} [r_1c_1, & r_1c_2, & r_1c_3, & r_1c_4, \\ r_2c_1, & r_2c_2, & r_2c_3, & r_2c_4, \\ r_3c_1, & r_3c_2, & r_3c_3, & r_3c_4, \\ 0.0, & 0.0, & 0.0, & 1.0] \end{array}$

std::vector<float> AL::Math::Transform::toVector ( void  ) const
void AL::Math::Transform::writeToVector ( std::vector< float >::iterator &  pIt) const

Write the Transform in the vector and update the iterator:

$ \begin{array}{cccc} [r_1c_1, & r_1c_2, & r_1c_3, & r_1c_4, \\ r_2c_1, & r_2c_2, & r_2c_3, & r_2c_4, \\ r_3c_1, & r_3c_2, & r_3c_3, & r_3c_4, \\ 0.0, & 0.0, & 0.0, & 1.0] \end{array}$ is assumed the vector has enough space.


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