Classes | Functions

decomp.h File Reference

This reference page is linked to from the following overview topics: World Space Modifiers and Object Transformations.


#include "maxheap.h"
#include "point3.h"
#include "quat.h"

Go to the source code of this file.

Classes

struct   AffineParts

Functions

CoreExport void  SpectralDecomp (Matrix3 m, Point3 &s, Quat &q)
CoreExport void  decomp_affine (Matrix3 A, AffineParts *parts)
CoreExport void  invert_affine (AffineParts *parts, AffineParts *inverse)

Function Documentation

CoreExport void SpectralDecomp ( Matrix3  m,
Point3 s,
Quat q 
)
Remarks:
This is another way to decompose a matrix into the scale and rotation parts (the position part can be retrieved from the bottom row of the matrix). This does not return correct results for off axis scale.
Parameters:
Matrix3 m
The input matrix to decompose.

Point3 &s
The scale from the matrix.

Quat& q
The rotation of the matrix.
CoreExport void decomp_affine ( Matrix3  A,
AffineParts parts 
)
Remarks:
This will decompose a matrix into the translation, rotation and scale components and store the results in the AffineParts structure passed. This will return correct results for off axis scale. This is a fairly computationally intensive iterative solution operation.
Parameters:
Matrix3 A
The input matrix to decompose.

AffineParts *parts
The result. See above.

Sample Code:
Note: If you want to rebuild a Matrix3 from the decomposed parts you get back from decomp_affine() the important thing is the order the parts are combined.

Consider the following matrices constructed from the various affine parts:
ptm = position component (t)
rtm = "essential" rotation (q)
srtm = "stretch" rotation (u)
stm = scale component (k)
ftm = the flip tm -> ScaleMatrix(Point3(ap.f,ap.f,ap.f));

Here's the correct way of reassembling the decomposed matrix:
Matrix3 srtm, rtm, ptm, stm, ftm;
ptm.IdentityMatrix();
ptm.SetTrans(ap.t);
ap.q.MakeMatrix(rtm);
ap.u.MakeMatrix(srtm);
stm = ScaleMatrix(ap.k);
mat = Inverse(srtm) * stm * srtm * rtm * ftm * ptm;
CoreExport void invert_affine ( AffineParts parts,
AffineParts inverse 
)
Remarks:
This is used to take the AffineParts and inverts them. This gives you the equivalent parts for the inverse matrix.
Parameters:
AffineParts *parts
The input AffineParts pointer.

AffineParts *inverse
The inverse of parts.