Main Page Namespace List Class Hierarchy Alphabetical List Compound List Namespace Members Compound Members Related Pages

# PajaTypes::DecomposeAffineC Class Reference

Decomposes a matrix into affine parts. More...

`#include <DecomposeAffineC.h>`

List of all members.

## Public Methods

- DecomposeAffineC ( const PajaTypes::Matrix3C& rMat )
- ~DecomposeAffineC ()
- PajaTypes::Vector3C get_translation ()
- PajaTypes::QuatC get_rotation ()
- PajaTypes::Vector3C get_scale ()
- PajaTypes::QuatC get_scale_rotation ()
- PajaTypes::float32 get_sign ()

## Detailed Description

Decomposes a matrix into affine parts.

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 & Destructor Documentation

DecomposeAffineC ( | const PajaTypes::Matrix3C & rMat )

| Constructor.

~DecomposeAffineC ( | )

| Desctructor.

## Member Function Documentation

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.

PajaTypes::float32 get_sign ( | )

| Returns sign of the determinant.

PajaTypes::Vector3C get_translation ( | )

| Returns the translation part of the matrix.

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

- DecomposeAffineC.h