Basic Interface to Alias transformation matrix.
#include <AlTM.h>
class AlTM
inline AlTM() ;
inline ~AlTM() ;
AlTM( const AlTM& );
AlTM( const double[4][4] );
AlTM( const double d0,const double d1,const double d2,const double d3 );
inline double* operator []( int row )
inline const double* operator []( int row ) const
statusCode getTM( double[4][4] ) const;
statusCode setTM( const double[4][4] );
AlTM& operator =( const AlTM& );
AlTM& operator =( const double d );
int operator ==( const AlTM& ) const;
int operator !=( const AlTM& ) const;
AlTM operator +( const AlTM& ) const;
AlTM operator -( const AlTM& ) const;
AlTM operator *( const AlTM& ) const;
AlTM operator *( const double ) const;
friend AlTM operator *( const double d, const AlTM& tm );
AlTM& operator +=( const AlTM& );
AlTM& operator -=( const AlTM& );
AlTM& operator *=( const AlTM& );
AlTM& operator *=( const double );
statusCode transPoint( double d[4] ) const;
statusCode transPoint( const double pt[4], double transPt[4] ) const;
statusCode transPoint( double& x, double &y, double &z, double &w ) const;
statusCode transPoint( double& x, double &y, double &z ) const; // assumes w = 1.0
statusCode transVector( double& x, double& y, double& z ) const;
statusCode transNormal( double& x, double& y, double& z ) const;
statusCode decompose ( double [3], double [3], double [3], double [3] ) const;
AlTM inverse( void ) const;
AlTM transpose( void ) const;
static AlTM identity( void );
static AlTM zero( void );
static AlTM diagonal( const double d0, const double d1, const double d2, const double d3 );
// standard transformations
static AlTM scale( const double );
static AlTM scale_nonp( const double, const double, const double );
static AlTM translate( const double, const double, const double );
static AlTM rotateX( const double );
static AlTM rotateY( const double );
static AlTM rotateZ( const double );
static AlTM rotate( double x, double y, double z, double angle );
This class encapsulates the functionality for creating, manipulating and deleting Alias 4x4 transformation matrices.
Transformation matrices are used to do linear transformations of a vector. Composite transformations are done by multiplying the individual transformations together.
The matrix is ordered as AlTM[y][x]:
0,0 0,1 0,2 0,3
1,0 1,1 1,2 1,3
2,0 2,1 2,2 2,3
3,0 3,1 3,2 3,3
The transformation matrix usually takes the form:
TM = | r00 r01 r02 0 |
| r10 r11 r12 0 |
| r20 r21 r22 0 |
| tx0 ty0 tz0 1 |
where tx0, ty0, tz0 are the aggregate translations and r(xy) is the aggregate product of rotations, scales and shears.
A point is transformed by considering the point to be a row vector of 4 elements and then post multiplying by the transformation matrix.
[x’ y’ z’ w’]
= [x y z w] | 00 01 02 03 |
| 10 11 12 13 |
| 20 21 22 23 |
| 30 31 32 33 |
If the w component is not specified, it is assumed to have a value of 1.
The static functions at the end of the class are used to create typical transformation matrices.
Note: the [] operator has been defined for the AlTM class. This means that the individual matrix elements can be addressed as if the AlTM were a standard 4x4 array of doubles. This eliminates the need to create a temporary 4x4 array to retrieve the values.
for example, AlTM matrix; matrix[3][2] = 10.0;
AlTM::AlTM( const double d0, const double d1, const double d2, const double d3 )
Constructor for the AlTM. This initializes the matrix by setting the diagonal to (d0,d1,d2,d3)
Warning: for efficiency reasons, the matrix is NOT initialized by the default constructor.
Use the AlTM(1,1,1,1) constructor to initialize the identity matrix (that is, this sets the diagonal to 1’s, and the rest of the matrix to 0)
Similarly, to initialize the matrix with all 0, use the constructor AlTM(0) or AlTM(0,0,0,0)
statusCode AlTM::decompose( double translate[3], double scale[3], double rotate[3], double shear[3] ) const
Decomposes the transform into translate, rotate, scale, and shear components.
The shears are saved as XY, XZ, and YZ in the return vector "shear". They may be ignored, but only at your peril! Alias transformation nodes can contain a shear despite the fact that there is no explicit shear operation (a two level DAG with rotate and scale will do it).
AlTM AlTM::diagonal( const double d0, const double d1, const double d2, const double d3 )
AlTM AlTM::scale_nonp( const double sx, const double sy, const double sz )
statusCode AlTM::transNormal( double& x, double& y, double& z ) const
Transforms a normal. sFailure is returned if the upper 3x3 matrix is not invertible n’ = n * trans(inv(M)).
NOTE: this function inverts the given matrix to do the operation. This operation may not be numerically accurate. It is suggested that, for DAG traversals, you use AlDagNode::inverseGlobalTransform to get the inverse of the transformation. Then take the transformation, then use transVector. for example,
double normX, normY, normZ;
AlTM invTM;
dagNode->inverseGlobalTransformMatrix( invTM );
invTM.transpose().transVector( normX, normY, normZ );
statusCode AlTM::transPoint( const double pt[4], double transPt[4] ) const
statusCode AlTM::transPoint( double &x, double &y, double &z, double &w ) const
statusCode AlTM::transPoint( double &x, double &y, double &z ) const