|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NLMISC::CMatrix Class ReferenceA 4*4 Homogenous Matrix.
More...
#include <matrix.h>
Collaboration diagram for NLMISC::CMatrix:
[legend]List of all members.
Public Types |
enum | TRotOrder {
XYZ,
XZY,
YXZ,
YZX,
ZXY,
ZYX
} |
| Rotation Order. More...
|
Public Methods |
|
| CMatrix () |
| Constructor which init to identity(). More...
|
| CMatrix (const CMatrix &) |
| Copy Constructor. More...
|
CMatrix& | operator= (const CMatrix &) |
| operator=. More...
|
|
void | identity () |
| Reset the matrix to identity. More...
|
void | setRot (const CVector &i, const CVector &j, const CVector &k, bool hintNoScale=false) |
| Explicit setup the Rotation/Scale matrix (base). More...
|
void | setRot (const float m33[9], bool hintNoScale=false) |
| Explicit setup the Rotation/Scale matrix (base). More...
|
void | setRot (const CVector &v, TRotOrder ro) |
| Explicit setup the Rotation matrix (base) as a Euler rotation matrix. More...
|
void | setRot (const CQuat &quat) |
| Explicit setup the Rotation matrix (base) as a Quaternion rotation matrix. More...
|
void | setRot (const CMatrix &matrix) |
| Explicit setup the Rotation/Scale matrix (base) with the rotation part of an other matrix. More...
|
void | setPos (const CVector &v) |
| Explicit setup the Translation component. More...
|
void | movePos (const CVector &v) |
| Explicit move the Translation component. More...
|
void | setProj (const float proj[4]) |
| Explicit setup the Projection component. More...
|
void | resetProj () |
| Reset the Projection component to 0 0 0 1. More...
|
void | set (const float m44[16]) |
| Explicit setup the 4*4 matrix. More...
|
|
void | getRot (CVector &i, CVector &j, CVector &k) const |
| Get the Rotation/Scale matrix (base). More...
|
void | getRot (float m33[9]) const |
| Get the Rotation/Scale matrix (base). More...
|
void | getRot (CQuat &quat) const |
| Get the Rotation matrix (base). More...
|
CQuat | getRot () const |
| Get the Rotation matrix (base). More...
|
void | getPos (CVector &v) const |
| Get the Translation component. More...
|
CVector | getPos () const |
| Get the Translation component. More...
|
void | getProj (float proj[4]) const |
| Get the Projection component. More...
|
CVector | getI () const |
| Get the I vector of the Rotation/Scale matrix (base). More...
|
CVector | getJ () const |
| Get the J vector of the Rotation/Scale matrix (base). More...
|
CVector | getK () const |
| Get the K vector of the Rotation/Scale matrix (base). More...
|
void | get (float m44[16]) const |
| Get 4*4 matrix. More...
|
const float* | get () const |
| Get 4*4 matrix. More...
|
|
void | translate (const CVector &v) |
| Apply a translation to the matrix. same as M=M*T. More...
|
void | rotateX (float a) |
| Apply a rotation on axis X to the matrix. More...
|
void | rotateY (float a) |
| Apply a rotation on axis Y to the matrix. More...
|
void | rotateZ (float a) |
| Apply a rotation on axis Z to the matrix. More...
|
void | rotate (const CVector &v, TRotOrder ro) |
| Apply a euler rotation. More...
|
void | rotate (const CQuat &quat) |
| Apply a quaternion rotation. More...
|
void | scale (float f) |
| Apply a uniform scale to the matrix. More...
|
void | scale (const CVector &scale) |
| Apply a non-uniform scale to the matrix. More...
|
|
CMatrix | operator * (const CMatrix &) const |
CMatrix& | operator *= (const CMatrix &) |
void | transpose3x3 () |
| transpose the rotation part only of the matrix (swap columns/lines). More...
|
void | transpose () |
| transpose the matrix (swap columns/lines). More...
|
void | invert () |
| Invert the matrix. More...
|
CMatrix | inverted () const |
| Return the matrix inverted. More...
|
bool | normalize (TRotOrder pref) |
| Normalize the matrix so that the rotation part is now an orthonormal basis, ie a rotation with no scale. More...
|
|
CVector | mulVector (const CVector &v) const |
| Multiply a normal. ie v.w=0 so the Translation component doesn't affect result. Projection doesn't affect result. More...
|
CVector | mulPoint (const CVector &v) const |
| Multiply a point. ie v.w=1 so the Translation component do affect result. Projection doesn't affect result. More...
|
CVector | operator * (const CVector &v) const |
| Multiply a point. -
See also:
-
mulPoint().
More...
|
CVectorH | operator * (const CVectorH& v) const |
| Multiply with an homogenous vector. More...
|
|
void | serial (IStream &f) |
bool | hasScalePart () const |
| return true if the matrix has a scale part (by scale(), by multiplication etc...). More...
|
bool | hasProjectionPart () const |
| return true if the matrix has a projection part (by setProj(), by multiplication etc...). More...
|
Static Public Attributes |
const CMatrix | Identity |
| The identity matrix. Same as CMatrix(). More...
|
Private Methods |
void | fastInvert33 (CMatrix &ret) const |
bool | slowInvert33 (CMatrix &ret) const |
bool | slowInvert44 (CMatrix &ret) const |
float& | mat (sint i, sint j) |
const float& | mat (sint i, sint j) const |
void | getCofactIndex (sint i, sint &l1, sint &l2, sint &l3) const |
bool | hasRot () const |
bool | hasTrans () const |
bool | hasProj () const |
bool | hasAll () const |
void | testExpandRot () const |
void | testExpandTrans () const |
void | testExpandProj () const |
Private Attributes |
float | M [16] |
float | Scale33 |
uint32 | StateBit |
Friends |
CPlane | operator * (const CPlane &p, const CMatrix &m) |
| Plane (line vector) multiplication. More...
|
Detailed Description
A 4*4 Homogenous Matrix.
This is a column matrix, so operations like: v1=A*B*C*v0 ; applies C first , then B, then A to vector v0.
Since it is a column matrix, the first column is the I vector of the base, 2nd is J, 3th is K.
4th column vector is T, the translation vector.
Angle orientation are: Xaxis: YtoZ. Yaxis: ZtoX. Zaxis: XtoY.
This matrix keep a matrix state to improve Matrix, vector and plane computing (matrix inversion, vector multiplication...). The internal matrix know if:
- matrix is identity
- matrix has a translation component
- matrix has a rotation component
- matrix has a uniform scale component (scale which is the same along the 3 axis)
- matrix has a non-uniform scale component
- matrix has a projection component (4th line of the matrix is not 0 0 0 1).
An example of improvement is that CMatrix::operator *(const CVector &v) return v if the matrix is identity.
By default, a matrix is identity. But for a performance view, this is just a StateBit=0... -
Author(s):
-
Lionel Berenguier , Nevrax France
-
Date:
-
2000
Definition at line 66 of file matrix.h.
Member Enumeration Documentation
enum NLMISC::CMatrix::TRotOrder
|
|
|
Rotation Order.
-
Enumeration values:
-
Definition at line 70 of file matrix.h. |
Constructor & Destructor Documentation
NLMISC::CMatrix::CMatrix (
|
) [inline]
|
|
NLMISC::CMatrix::CMatrix (
|
const CMatrix & m )
|
|
Member Function Documentation
void NLMISC::CMatrix::fastInvert33 (
|
CMatrix & ret ) const [private]
|
|
const float * NLMISC::CMatrix::get (
|
) const
|
|
|
Get 4*4 matrix.
-
Returns:
-
the matrix's 4*4 column matrix (4x4 matrix stored in column-major order as 16 consecutive values)
Definition at line 471 of file matrix.cpp. |
void NLMISC::CMatrix::get (
|
float m44[16] ) const
|
|
|
Get 4*4 matrix.
-
Parameters:
-
m44
|
the matrix's 4*4 column matrix (4x4 matrix stored in column-major order as 16 consecutive values) |
Definition at line 462 of file matrix.cpp. |
void NLMISC::CMatrix::getCofactIndex (
|
sint i,
|
|
sint & l1,
|
|
sint & l2,
|
|
sint & l3 ) const [inline, private]
|
|
CVector NLMISC::CMatrix::getI (
|
) const
|
|
CVector NLMISC::CMatrix::getJ (
|
) const
|
|
CVector NLMISC::CMatrix::getK (
|
void ) const
|
|
CVector NLMISC::CMatrix::getPos (
|
void ) const
|
|
void NLMISC::CMatrix::getPos (
|
CVector & v ) const
|
|
|
Get the Translation component.
-
Parameters:
-
v
|
the matrix's translation vector. |
Definition at line 404 of file matrix.cpp. |
void NLMISC::CMatrix::getProj (
|
float proj[4] ) const
|
|
|
Get the Projection component.
-
Parameters:
-
proj
|
the matrix's projection vector. |
Definition at line 420 of file matrix.cpp. |
CQuat NLMISC::CMatrix::getRot (
|
) const [inline]
|
|
|
Get the Rotation matrix (base).
-
Parameters:
-
quat
|
the return quaternion. |
Definition at line 179 of file matrix.h. |
void NLMISC::CMatrix::getRot (
|
CQuat & quat ) const
|
|
|
Get the Rotation matrix (base).
-
Parameters:
-
quat
|
the return quaternion. |
Definition at line 1377 of file matrix.cpp. |
void NLMISC::CMatrix::getRot (
|
float m33[9] ) const
|
|
|
Get the Rotation/Scale matrix (base).
-
Parameters:
-
m33
|
the matrix's 3*3 column rotation matrix. (3x3 matrix stored in column-major order as 9 consecutive values) |
Definition at line 372 of file matrix.cpp. |
|
Get the Rotation/Scale matrix (base).
-
Parameters:
-
i
|
The matrix's I vector of the cartesian base. |
j
|
The matrix's J vector of the cartesian base. |
k
|
The matrix's K vector of the cartesian base. |
Definition at line 356 of file matrix.cpp. |
bool NLMISC::CMatrix::hasAll (
|
) const [inline, private]
|
|
bool NLMISC::CMatrix::hasProj (
|
) const [inline, private]
|
|
bool NLMISC::CMatrix::hasProjectionPart (
|
) const
|
|
|
return true if the matrix has a projection part (by setProj(), by multiplication etc...).
Definition at line 95 of file matrix.cpp. |
bool NLMISC::CMatrix::hasRot (
|
) const [inline, private]
|
|
bool NLMISC::CMatrix::hasScalePart (
|
) const
|
|
|
return true if the matrix has a scale part (by scale(), by multiplication etc...).
Definition at line 91 of file matrix.cpp. |
bool NLMISC::CMatrix::hasTrans (
|
) const [inline, private]
|
|
void NLMISC::CMatrix::identity (
|
)
|
|
void NLMISC::CMatrix::invert (
|
)
|
|
CMatrix NLMISC::CMatrix::inverted (
|
) const
|
|
const float & NLMISC::CMatrix::mat (
|
sint i,
|
|
sint j ) const [inline, private]
|
|
float & NLMISC::CMatrix::mat (
|
sint i,
|
|
sint j ) [inline, private]
|
|
void NLMISC::CMatrix::movePos (
|
const CVector & v )
|
|
|
Explicit move the Translation component.
-
Parameters:
-
v
|
a vector to move the translation vector. |
Definition at line 276 of file matrix.cpp. |
|
Multiply a point. ie v.w=1 so the Translation component do affect result. Projection doesn't affect result.
Definition at line 1250 of file matrix.cpp. |
bool NLMISC::CMatrix::normalize (
|
TRotOrder ro )
|
|
|
Normalize the matrix so that the rotation part is now an orthonormal basis, ie a rotation with no scale.
NB: projection part and translation part are not modified. -
Parameters:
-
pref
|
the preference axis order to normalize. ZYX means that K direction will be kept, and the plane JK will be used to lead the I vector. |
-
Returns:
-
false if One of the vector basis is null. true otherwise.
Definition at line 1159 of file matrix.cpp.
Referenced by NL3D::CQuadTree::selectRay(), and NL3D::CQuadTree::selectSegment(). |
|
Multiply with an homogenous vector.
Definition at line 1279 of file matrix.cpp. |
CVector NLMISC::CMatrix::operator * (
|
const CVector & v ) const [inline]
|
|
CMatrix NLMISC::CMatrix::operator * (
|
const CMatrix & m ) const
|
|
CMatrix & NLMISC::CMatrix::operator *= (
|
const CMatrix & m )
|
|
CMatrix & NLMISC::CMatrix::operator= (
|
const CMatrix & m )
|
|
void NLMISC::CMatrix::resetProj (
|
)
|
|
|
Reset the Projection component to 0 0 0 1.
Definition at line 309 of file matrix.cpp. |
void NLMISC::CMatrix::rotate (
|
const CQuat & quat )
|
|
|
Apply a quaternion rotation.
Definition at line 662 of file matrix.cpp. |
|
Apply a euler rotation.
-
Parameters:
-
v
|
a vector of 3 angle (in radian), giving rotation around each axis (x,y,z) |
ro
|
the order of transformation applied. if ro==XYZ, then the transform is M=M*Rx*Ry*Rz |
Definition at line 644 of file matrix.cpp. |
void NLMISC::CMatrix::rotateX (
|
float a )
|
|
|
Apply a rotation on axis X to the matrix.
same as M=M*Rx -
Parameters:
-
Definition at line 524 of file matrix.cpp. |
void NLMISC::CMatrix::rotateY (
|
float a )
|
|
|
Apply a rotation on axis Y to the matrix.
same as M=M*Ry -
Parameters:
-
Definition at line 564 of file matrix.cpp. |
void NLMISC::CMatrix::rotateZ (
|
float a )
|
|
|
Apply a rotation on axis Z to the matrix.
same as M=M*Rz -
Parameters:
-
Definition at line 604 of file matrix.cpp. |
void NLMISC::CMatrix::scale (
|
const CVector & v )
|
|
|
Apply a non-uniform scale to the matrix.
Definition at line 695 of file matrix.cpp. |
void NLMISC::CMatrix::scale (
|
float f )
|
|
|
Apply a uniform scale to the matrix.
Definition at line 670 of file matrix.cpp. |
void NLMISC::CMatrix::serial (
|
IStream & f )
|
|
void NLMISC::CMatrix::set (
|
const float m44[16] )
|
|
|
Explicit setup the 4*4 matrix.
Avoid it. It implies low compute since no check is done on rotation matrix to see what type of matrix it is (identity, rotation, scale, uniform scale). BUT check are made to see if it has translation or projection components. -
Parameters:
-
m44
|
the 4*4 column matrix (4x4 matrix stored in column-major order as 16 consecutive values) |
Definition at line 320 of file matrix.cpp. |
void NLMISC::CMatrix::setPos (
|
const CVector & v )
|
|
|
Explicit setup the Translation component.
v==Null is tested to see if the matrix now have a translation component. -
Parameters:
-
v
|
the translation vector. |
Definition at line 261 of file matrix.cpp. |
void NLMISC::CMatrix::setProj (
|
const float proj[4] )
|
|
|
Explicit setup the Projection component.
Proj is tested to see if the matrix now have a projection component. -
Parameters:
-
proj
|
the 4th line of the matrix. Set it to 0 0 0 1 to reset it to default. |
Definition at line 291 of file matrix.cpp. |
void NLMISC::CMatrix::setRot (
|
const CMatrix & matrix )
|
|
|
Explicit setup the Rotation/Scale matrix (base) with the rotation part of an other matrix.
-
Parameters:
-
matrix
|
the matrix to copy rot part. |
Definition at line 241 of file matrix.cpp. |
void NLMISC::CMatrix::setRot (
|
const CQuat & quat )
|
|
|
Explicit setup the Rotation matrix (base) as a Quaternion rotation matrix.
-
Parameters:
-
Definition at line 1338 of file matrix.cpp. |
|
Explicit setup the Rotation matrix (base) as a Euler rotation matrix.
-
Parameters:
-
v
|
a vector of 3 angle (in radian), giving rotation around each axis (x,y,z) |
ro
|
the order of transformation applied. if ro==XYZ, then the transform is M=M*Rx*Ry*Rz |
Definition at line 229 of file matrix.cpp. |
void NLMISC::CMatrix::setRot (
|
const float m33[9],
|
|
bool hintNoScale = false )
|
|
|
Explicit setup the Rotation/Scale matrix (base).
Avoid it. It implies low compute since no check is done on m33 to see what type of matrix it is (identity, raotation, scale, uniform scale) -
Parameters:
-
m33
|
the 3*3 column rotation matrix. (3x3 matrix stored in column-major order as 9 consecutive values) |
hintNoScale
|
set it to true if you are sure that your rot matrix is a pure rot matrix with no scale. If set to true and your rotation is not an orthonormal basis, unpredictable result are excepted. |
Definition at line 218 of file matrix.cpp. |
void NLMISC::CMatrix::setRot (
|
const CVector & i,
|
|
const CVector & j,
|
|
const CVector & k,
|
|
bool hintNoScale = false )
|
|
|
Explicit setup the Rotation/Scale matrix (base).
Avoid it. It implies low compute since no check is done on base to see what type of matrix it is (identity, rotation, scale, uniform scale...) -
Parameters:
-
i
|
The I vector of the cartesian base. |
j
|
The J vector of the cartesian base. |
k
|
The K vector of the cartesian base. |
hintNoScale
|
set it to true if you are sure that your rot matrix is a pure rot matrix with no scale. If set to true and your rotation is not an orthonormal basis, unpredictable result are excepted. |
Definition at line 207 of file matrix.cpp.
Referenced by CTrackKeyFramerTCB< CKeyTCBQuat,NLMISC::CAngleAxis >::compile(), NL3D::CQuadTree::selectRay(), and NL3D::CQuadTree::selectSegment(). |
bool NLMISC::CMatrix::slowInvert33 (
|
CMatrix & ret ) const [private]
|
|
bool NLMISC::CMatrix::slowInvert44 (
|
CMatrix & ret ) const [private]
|
|
void NLMISC::CMatrix::testExpandProj (
|
) const [inline, private]
|
|
void NLMISC::CMatrix::testExpandRot (
|
) const [inline, private]
|
|
void NLMISC::CMatrix::testExpandTrans (
|
) const [inline, private]
|
|
void NLMISC::CMatrix::translate (
|
const CVector & v )
|
|
|
Apply a translation to the matrix. same as M=M*T.
-
Parameters:
-
ro
|
the RotOrder which show how to get the euler. |
-
Returns:
-
one solution of Euler angle. A rotate() with this value and the RotOrder ro will give the same matrix.
-
Todo:
-
TODO.
Definition at line 491 of file matrix.cpp. |
void NLMISC::CMatrix::transpose (
|
)
|
|
|
transpose the matrix (swap columns/lines).
NB: this transpose the 4*4 matrix entirely (even proj/translate part).
Definition at line 925 of file matrix.cpp. |
void NLMISC::CMatrix::transpose3x3 (
|
)
|
|
|
transpose the rotation part only of the matrix (swap columns/lines).
Definition at line 912 of file matrix.cpp. |
Friends And Related Function Documentation
CPlane operator * (
|
const CPlane & p,
|
|
const CMatrix & m ) [friend]
|
|
|
Plane (line vector) multiplication.
Definition at line 1298 of file matrix.cpp. |
Member Data Documentation
const CMatrix NLMISC::CMatrix::Identity [static]
|
|
float NLMISC::CMatrix::M[16] [private]
|
|
float NLMISC::CMatrix::Scale33 [private]
|
|
uint32 NLMISC::CMatrix::StateBit [private]
|
|
The documentation for this class was generated from the following files:
|
|