#include <DecomposeAffineC.h>
Public Methods | |
DecomposeAffineC (const PajaTypes::Matrix3C &rMat) | |
Constructor. | |
~DecomposeAffineC () | |
Desctructor. | |
PajaTypes::float32 | get_sign () |
Returns sign of the determinant. | |
Public Attributes | |
PajaTypes::Vector3C | get_translation () |
Returns the translation part of the matrix. | |
PajaTypes::QuatC | get_rotation () |
Return essential rotation part of the matrix. | |
PajaTypes::Vector3C | get_scale () |
Return scale part of the matrix. | |
PajaTypes::QuatC | get_scale_rotation () |
Return scale rotation part of the matrix. |
Decomposes matrix into translation, rotation, scale and scael rotation parts. The class is based on the article: "Polar Matrix Decomposition" by Ken Shoemake, shoemake@graphics.cis.upenn.edu in "Graphics Gems IV", Academic Press, 1994
To reassemble the matrix use following:
Matrix3C rScaleMat, rScaleRotMat, rInvScaleRotMat; Matrix3C rPosMat, rRotMat, rTM; QuatC rInvScaleRot; // scale rScaleMat.set_scale( rScale ); // scale rot rScaleRot.from_axis_angle( rScaleAxis, f32ScaleAngle ); rScaleRotMat.set_rot( rScaleRot ); // inv scale rot rInvScaleRot = rScaleRot.unit_inverse(); rInvScaleRotMat.set_rot( rInvScaleRot ); // rot rRot.from_axis_angle( rRotAxis, f32RotAngle ); rRotMat.set_rot( rRot ); // pos rPosMat.set_trans( rPos ); // Compose matrix rTM = rInvScaleRotMat * rScaleMat * rScaleRotMat * rRotMat * rPosMat;
Or using OpenGL:
float32 f32X, f32Y, f32Z, f32A; QuatC rInvScaleRot = rScaleRot.unit_inverse(); glTranslatef( rPos[0], rPos[1], rPos[2] ); rRot.to_axis_angle( f32X, f32Y, f32Z, f32A ); glRotatef( f32A / (float32)M_PI * 180.0f, f32X, f32Y, f32Z ); rScaleRot.to_axis_angle( f32X, f32Y, f32Z, f32A ); glRotatef( f32A / (float32)M_PI * 180.0f, f32X, f32Y, f32Z ); glScalef( rScale[0], rScale[1], rScale[2] ); rInvScaleRot.to_axis_angle( f32X, f32Y, f32Z, f32A ); glRotatef( f32A / (float32)M_PI * 180.0f, f32X, f32Y, f32Z );
|
Constructor.
|
|
Desctructor.
|
|
Returns sign of the determinant.
|
|
Return essential rotation part of the matrix.
|
|
Return scale part of the matrix.
|
|
Return scale rotation part of the matrix.
|
|
Returns the translation part of the matrix.
|