NLMISC::CMatrix Class Reference

A 4*4 Homogeneous Matrix. More...

#include <matrix.h>

List of all members.

Public Types

enum  TRotOrder {
  XYZ, XZY, YXZ, YZX,
  ZXY, ZYX
}
 

Rotation Order.

More...

Public Member Functions

void setArbitraryRotI (const CVector &idir)
 Choose an arbitrary rotation matrix for the given direction.
void setArbitraryRotJ (const CVector &jdir)
 Choose an arbitrary rotation matrix for the given direction.
void setArbitraryRotK (const CVector &kdir)
 Choose an arbitrary rotation matrix for the given direction.
Object



 CMatrix ()
 Constructor which init to identity().
 CMatrix (const CMatrix &)
 Copy Constructor.
CMatrixoperator= (const CMatrix &)
 operator=.
Sets



void identity ()
 Reset the matrix to identity.
void setRot (const CVector &i, const CVector &j, const CVector &k, bool hintNoScale=false)
 Explicit setup the Rotation/Scale matrix (base).
void setRot (const float m33[9], bool hintNoScale=false)
 Explicit setup the Rotation/Scale matrix (base).
void setRot (const CVector &v, TRotOrder ro)
 Explicit setup the Rotation matrix (base) as a Euler rotation matrix.
void setRot (const CQuat &quat)
 Explicit setup the Rotation matrix (base) as a Quaternion rotation matrix.
void setRot (const CMatrix &matrix)
 Explicit setup the Rotation/Scale matrix (base) with the rotation part of an other matrix.
void setScale (float scale)
 Explicit setup the Rotation/Scale matrix (base) with a scale (=> matrix has no Rotation).
void setScale (const CVector &v)
 Explicit setup the Rotation/Scale matrix (base) with a scale (=> matrix has no Rotation).
void setPos (const CVector &v)
 Explicit setup the Translation component.
void movePos (const CVector &v)
 Explicit move the Translation component.
void setProj (const float proj[4])
 Explicit setup the Projection component.
void resetProj ()
 Reset the Projection component to 0 0 0 1.
void set (const float m44[16])
 Explicit setup the 4*4 matrix.
void setCoefficient (float coeff, sint i, sint j)
 Setup the (i, j) matrix coefficient.
Gets.



void getRot (CVector &i, CVector &j, CVector &k) const
 Get the Rotation/Scale matrix (base).
void getRot (float m33[9]) const
 Get the Rotation/Scale matrix (base).
void getRot (CQuat &quat) const
 Get the Rotation matrix (base).
CQuat getRot () const
 Get the Rotation matrix (base).
void getPos (CVector &v) const
 Get the Translation component.
const CVectorgetPos () const
 Get the Translation component.
void getProj (float proj[4]) const
 Get the Projection component.
CVector getI () const
 Get the I vector of the Rotation/Scale matrix (base).
CVector getJ () const
 Get the J vector of the Rotation/Scale matrix (base).
CVector getK () const
 Get the K vector of the Rotation/Scale matrix (base).
void get (float m44[16]) const
 Get 4*4 matrix.
const floatget () const
 Get 4*4 matrix.
3D Operations.



void translate (const CVector &v)
 Apply a translation to the matrix. same as M=M*T.
void rotateX (float a)
 Apply a rotation on axis X to the matrix.
void rotateY (float a)
 Apply a rotation on axis Y to the matrix.
void rotateZ (float a)
 Apply a rotation on axis Z to the matrix.
void rotate (const CVector &v, TRotOrder ro)
 Apply a Euler rotation.
void rotate (const CQuat &quat)
 Apply a quaternion rotation.
void scale (float f)
 Apply a uniform scale to the matrix.
void scale (const CVector &scale)
 Apply a non-uniform scale to the matrix.
Matrix Operations.



void setMulMatrix (const CMatrix &m1, const CMatrix &m2)
 Matrix multiplication.
CMatrix operator* (const CMatrix &in) const
 Matrix multiplication.
CMatrixoperator*= (const CMatrix &in)
 equivalent to M=M*in
void setMulMatrixNoProj (const CMatrix &m1, const CMatrix &m2)
 Matrix multiplication assuming no projection at all in m1/m2 and Hence this.
void transpose3x3 ()
 transpose the rotation part only of the matrix (swap columns/lines).
void transpose ()
 transpose the matrix (swap columns/lines).
void invert ()
 Invert the matrix.
CMatrix inverted () const
 Return the matrix inverted.
bool normalize (TRotOrder pref)
 Normalize the matrix so that the rotation part is now an orthonormal basis, ie a rotation with no scale.



CVector mulVector (const CVector &v) const
 \ Vector Operations.
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.
CVector operator* (const CVector &v) const
 Multiply a point.
CVectorH operator* (const CVectorH &v) const
 Multiply with an homogeneous vector.
Misc



void serial (IStream &f)
bool hasScalePart () const
 return true if the matrix has a scale part (by scale(), by multiplication etc...)
bool hasScaleUniform () const
 return true if hasScalePart() and if if this scale is uniform.
float getScaleUniform () const
 return true the uniform scale. valid only if hasScaleUniform() is true, else 1 is returned.
bool hasProjectionPart () const
 return true if the matrix has a projection part (by setProj(), by multiplication etc...)

Static Public Attributes

static const CMatrix Identity
 The identity matrix. Same as CMatrix().

Private Member Functions

bool fastInvert33 (CMatrix &ret) const
bool slowInvert33 (CMatrix &ret) const
bool slowInvert44 (CMatrix &ret) const
floatmat (sint i, sint j)
const floatmat (sint i, sint j) const
void getCofactIndex (sint i, sint &l1, sint &l2, sint &l3) const
bool hasTrans () const
bool hasRot () const
bool hasProj () const
bool hasAll () const
void testExpandRot () const
void testExpandProj () const
void setScaleUni (float scale)

Private Attributes

float M [16]
float Scale33
uint32 StateBit

Friends

CPlane operator* (const CPlane &p, const CMatrix &m)
 Plane (line vector) multiplication.

Detailed Description

A 4*4 Homogeneous 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:

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:
Lionel Berenguier
Nevrax France
Date:
2000

Definition at line 63 of file matrix.h.


Member Enumeration Documentation

Rotation Order.

Enumerator:
XYZ 
XZY 
YXZ 
YZX 
ZXY 
ZYX 

Definition at line 67 of file matrix.h.


Constructor & Destructor Documentation

NLMISC::CMatrix::CMatrix (  )  [inline]

Constructor which init to identity().

Definition at line 85 of file matrix.h.

References M, and StateBit.

NLMISC::CMatrix::CMatrix ( const CMatrix m  ) 

Copy Constructor.

Definition at line 161 of file matrix.cpp.


Member Function Documentation

bool NLMISC::CMatrix::fastInvert33 ( CMatrix ret  )  const [private]

Definition at line 966 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, MAT_SCALEUNI, Scale33, and StateBit.

Referenced by inverted().

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 448 of file matrix.cpp.

References M, testExpandProj(), and testExpandRot().

void NLMISC::CMatrix::get ( float  m44[16]  )  const
void NLMISC::CMatrix::getCofactIndex ( sint  i,
sint l1,
sint l2,
sint l3 
) const [inline, private]

Definition at line 388 of file matrix.h.

Referenced by slowInvert44().

CVector NLMISC::CMatrix::getI (  )  const
CVector NLMISC::CMatrix::getJ (  )  const
CVector NLMISC::CMatrix::getK ( void   )  const
const CVector& NLMISC::CMatrix::getPos ( void   )  const [inline]

Get the Translation component.

NB: a const & works because it is a column vector

Returns:
the matrix's translation vector.

Definition at line 224 of file matrix.h.

References M.

void NLMISC::CMatrix::getPos ( CVector v  )  const [inline]

Get the Translation component.

Parameters:
v the matrix's translation vector.

Definition at line 219 of file matrix.h.

References M, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::CLightingManager::addDynamicLight(), NL3D::CVegetableManager::addInstance(), NL3D::CLodCharacterManager::addRenderCharacterKey(), NL3D::CShadowMap::buildClipInfoFromMatrix(), NL3D::CShadowMap::buildProjectionInfos(), NL3D::CWaveMakerShape::clip(), NL3D::CTransformShape::clip(), NL3D::CFlareShape::clip(), NL3D::CClipTrav::clipShadowCasters(), NL3D::CBone::compute(), NL3D::CSkeletonModel::computeDisplayLodCharacterPriority(), NL3D::CShadowMapManager::computeShadowDirection(), NL3D::CMaterial::decompUserTexMat(), NL3D::CPSUtil::displayBasis(), NL3D::CLodCharacterManager::fastIntersect(), NL3D::CWaterModel::fillVBHard(), NL3D::CWaterModel::fillVBSoft(), NL3D::CVegetable::generateInstance(), NL3D::CSkeletonModel::generateShadowMap(), NL3D::CWaterModel::getAttenuatedHeight(), NL3D::CParticleSystem::getDistFromViewer(), NL3D::CTransformShape::getLightHotSpotInWorld(), NL3D::CSkeletonModel::getLightHotSpotInWorld(), NL3D::CParticleSystem::getLOD(), NL3D::CParticleSystem::getLODVect(), NL3D::CWaterModel::getNumWantedVertices(), NLPACS::UMoveContainer::getPACSCoordsFromMatrix(), NL3D::CViewport::getRayWithPoint(), NL3D::CEvent3dMouseListener::getViewMatrix(), NL3D::CLightingManager::insertStaticLightedModel(), NL3D::CBone::interpolateBoneSkinMatrix(), NL3D::CParticleSystem::interpolateFXPosDelta(), NL3D::CParticleSystem::interpolateUserPosDelta(), NL3D::ITransformable::lookAt(), NL3D::CEvent3dMouseListener::operator()(), NL3D::CParticleSystemModel::refreshRscDeletion(), NL3D::CComputedString::render2D(), NL3D::CSkeletonModel::renderCLod(), NL3D::CSkeletonModel::renderIntoSkeletonShadowMap(), NL3D::CMeshInstance::renderIntoSkeletonShadowMap(), NL3D::CShadowMapManager::renderProject(), NL3D::CShadowMapManager::selectShadowMapsToGenerate(), NL3D::CPSZoneRectangle::setMatrix(), NL3D::CPSZoneCylinder::setMatrix(), NL3D::CPSZoneDisc::setMatrix(), NL3D::CPSZoneSphere::setMatrix(), NL3D::CPSZonePlane::setMatrix(), NL3D::CPSCylindricVortex::setMatrix(), NL3D::CPSSphericalEmitter::setMatrix(), NL3D::CPSEmitterRectangle::setMatrix(), NL3D::CParticleSystem::setNumTris(), NL3D::CParticleSystem::setSysMat(), NL3D::CDriverGL::setupModelMatrix(), NL3D::CParticleSystem::setUserMatrix(), NL3D::CParticleSystem::step(), NL3D::CRenderTrav::traverse(), NL3D::CWaveMakerModel::traverseAnimDetail(), NL3D::CSkeletonModel::traverseAnimDetail(), NL3D::CParticleSystemModel::traverseClip(), NL3D::CTransformShape::traverseLoadBalancingPass0(), NL3D::CWaterModel::traverseRender(), NL3D::CFlareModel::traverseRender(), NL3D::CTravCameraScene::update(), NL3D::CWaterModel::updateDiffuseMapMatrix(), and NL3D::CFlareModel::updateOcclusionQuery().

void NLMISC::CMatrix::getProj ( float  proj[4]  )  const

Get the Projection component.

Parameters:
proj the matrix's projection vector.

Definition at line 399 of file matrix.cpp.

References a41, a42, a43, a44, and hasProj().

CQuat NLMISC::CMatrix::getRot (  )  const [inline]

Get the Rotation matrix (base).

Parameters:
quat the return quaternion.

Definition at line 215 of file matrix.h.

References getRot().

Referenced by getRot().

void NLMISC::CMatrix::getRot ( CQuat quat  )  const

Get the Rotation matrix (base).

Parameters:
quat the return quaternion.

Definition at line 1385 of file matrix.cpp.

References NLMISC::CQuat::Identity, mat(), MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, normalize(), StateBit, NLMISC::CQuatT< T >::w, NLMISC::CQuatT< T >::x, NLMISC::CQuatT< T >::y, NLMISC::CQuatT< T >::z, and ZYX.

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 367 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, and hasRot().

void NLMISC::CMatrix::getRot ( CVector i,
CVector j,
CVector k 
) const

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 351 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, hasRot(), and NLMISC::CVector::set().

Referenced by NL3D::CTargetAnimCtrl::execute(), NL3D::CTargetAnimCtrl::getCurrentLSRotationFromBone(), NL3D::ITransformable::lookAt(), setRot(), and NL3D::UTransformable::setRotQuat().

float NLMISC::CMatrix::getScaleUniform (  )  const

return true the uniform scale. valid only if hasScaleUniform() is true, else 1 is returned.

Definition at line 104 of file matrix.cpp.

References hasScaleUniform(), and Scale33.

Referenced by NLMISC::CBSphere::applyTransform(), and NL3D::CCameraCol::setApplyMatrix().

bool NLMISC::CMatrix::hasAll (  )  const [inline, private]

Definition at line 127 of file matrix.cpp.

References hasProj(), hasRot(), and hasTrans().

Referenced by operator=().

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 94 of file matrix.cpp.

References MAT_PROJ, and StateBit.

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 90 of file matrix.cpp.

References MAT_SCALEANY, MAT_SCALEUNI, and StateBit.

Referenced by NLMISC::CBSphere::applyTransform(), NL3D::CDriverGL::doRefreshRenderSetup(), NL3D::CCameraCol::setApplyMatrix(), and NL3D::CDriverD3D::updateMatrices().

bool NLMISC::CMatrix::hasScaleUniform (  )  const

return true if hasScalePart() and if if this scale is uniform.

Definition at line 100 of file matrix.cpp.

References MAT_SCALEANY, MAT_SCALEUNI, and StateBit.

Referenced by NLMISC::CBSphere::applyTransform(), getScaleUniform(), serial(), NL3D::CCameraCol::setApplyMatrix(), setMulMatrixNoProj(), and setRot().

bool NLMISC::CMatrix::hasTrans (  )  const [inline, private]

Definition at line 119 of file matrix.cpp.

References MAT_TRANS, and StateBit.

Referenced by hasAll(), mulPoint(), serial(), setMulMatrix(), and transpose().

void NLMISC::CMatrix::identity (  ) 

Reset the matrix to identity.

Definition at line 198 of file matrix.cpp.

References a14, a24, a34, MAT_IDENTITY, and StateBit.

Referenced by NLLIGO::CZoneTemplate::build(), NLLIGO::CZoneEdge::buildMatrix(), NL3D::CCloud::calcBill(), NL3D::CCubeGrid< TCell >::CCubeGrid(), NL3D::CDriverD3D::CDriverD3D(), NL3D::CEvent3dMouseListener::CEvent3dMouseListener(), NL3D::CStaticQuadGrid< T >::clear(), NL3D::CLandscapeModel::clipAndRenderLandscape(), NLPACS::CQuadGrid< T >::CQuadGrid(), NL3D::CQuadTree< T >::CQuadTree(), NL3D::CStaticQuadGrid< T >::CStaticQuadGrid(), NL3D::CTransform::CTransform(), NL3D::CTravCameraScene::CTravCameraScene(), NL3D::CCloud::disp(), NL3D::CDRU::drawBitmap(), NL3D::CDRU::drawLine(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CCloud::genBill(), NL3D::CInstanceGroup::getInstanceMatrix(), NL3D::CWaterShape::getShapeInWorldSpace(), NL3D::CQuadGrid< T >::initCons(), InitZBuffer(), inverted(), NL3D::ITransformable::lookAt(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NEL3DCalcBase(), NL3D::NEL3DCalcBase(), NL3D::CEvent3dMouseListener::operator()(), NL3D::CVegetableManager::render(), NL3D::CComputedString::render2D(), rotate(), NL3D::CQuadTree< T >::selectRay(), NL3D::CQuadTree< T >::selectSegment(), serial(), NL3D::CDriverUser::setMatrixMode2D(), NL3D::CCloud::setMode2D(), setMulMatrix(), setRot(), NL3D::CDriverGL::setupViewMatrix(), NL3D::CDriverGL::setupViewMatrixEx(), NL3D::CPSGravity::show(), NLSOUND::CListenerFMod::updateFModPos(), NL3D::ITransformable::updateMatrix(), and NL3D::CPSMesh::updatePos().

void NLMISC::CMatrix::invert (  ) 
CMatrix NLMISC::CMatrix::inverted (  )  const
const float& NLMISC::CMatrix::mat ( sint  i,
sint  j 
) const [inline, private]

Definition at line 383 of file matrix.h.

References M.

float& NLMISC::CMatrix::mat ( sint  i,
sint  j 
) [inline, private]

Definition at line 378 of file matrix.h.

References M.

Referenced by getRot(), and slowInvert44().

void NLMISC::CMatrix::movePos ( const CVector v  ) 

Explicit move the Translation component.

Parameters:
v a vector to move the translation vector.

Definition at line 277 of file matrix.cpp.

References a14, a24, a34, MAT_TRANS, StateBit, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

CVector NLMISC::CMatrix::mulPoint ( const CVector v  )  const

Multiply a point. ie v.w=1 so the Translation component do affect result. Projection doesn't affect result.

Definition at line 1263 of file matrix.cpp.

References a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, hasRot(), hasTrans(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::CCloud::calcBill(), operator*(), NL3D::CMeshMultiLodInstance::setPosCoarseMesh(), and NL3D::CPortal::setWorldMatrix().

CVector NLMISC::CMatrix::mulVector ( const CVector v  )  const
bool NLMISC::CMatrix::normalize ( TRotOrder  pref  ) 

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 1173 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, getI(), getJ(), getK(), NLMISC::CVector::isNull(), MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, NLMISC::CVector::normalize(), Scale33, StateBit, testExpandRot(), NLMISC::CVector::x, XYZ, XZY, NLMISC::CVector::y, YXZ, YZX, NLMISC::CVector::z, ZXY, and ZYX.

Referenced by NL3D::CCameraCol::build(), CTrackKeyFramerTCB< CKeyTCBQuat, NLMISC::CAngleAxis >::compile(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CSkeletonSpawnScript::evaluate(), NL3D::CTargetAnimCtrl::execute(), NL3D::CPatch::generateTileVegetable(), getRot(), NL3D::CEvent3dMouseListener::operator()(), NL3D::CQuadTree< T >::selectRay(), NL3D::CQuadTree< T >::selectSegment(), setArbitraryRotI(), setArbitraryRotJ(), setArbitraryRotK(), NL3D::UTransformable::setRotQuat(), NLSOUND::CListenerFMod::updateFModPos(), and NL3D::CTransform::updateWorldMatrixFromFather().

CVectorH NLMISC::CMatrix::operator* ( const CVectorH v  )  const

Multiply with an homogeneous vector.

Definition at line 1292 of file matrix.cpp.

References a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44, testExpandProj(), testExpandRot(), NLMISC::CVectorH::w, NLMISC::CVectorH::x, NLMISC::CVectorH::y, and NLMISC::CVectorH::z.

CVector NLMISC::CMatrix::operator* ( const CVector v  )  const [inline]

Multiply a point.

See also:
mulPoint

Definition at line 341 of file matrix.h.

References mulPoint().

CMatrix NLMISC::CMatrix::operator* ( const CMatrix in  )  const [inline]

Matrix multiplication.

Definition at line 287 of file matrix.h.

References setMulMatrix().

CMatrix& NLMISC::CMatrix::operator*= ( const CMatrix in  )  [inline]

equivalent to M=M*in

Definition at line 294 of file matrix.h.

References setMulMatrix().

CMatrix & NLMISC::CMatrix::operator= ( const CMatrix m  ) 

operator=.

Definition at line 166 of file matrix.cpp.

References a11, a12, a13, a14, a41, a42, a43, a44, hasAll(), hasProj(), hasRot(), M, MAT_VALIDALL, Scale33, and StateBit.

void NLMISC::CMatrix::resetProj (  ) 

Reset the Projection component to 0 0 0 1.

Definition at line 307 of file matrix.cpp.

References a41, a42, a43, a44, MAT_PROJ, MAT_VALIDPROJ, and StateBit.

void NLMISC::CMatrix::rotate ( const CQuat quat  ) 

Apply a quaternion rotation.

Definition at line 633 of file matrix.cpp.

References setRot().

void NLMISC::CMatrix::rotate ( const CVector v,
TRotOrder  ro 
)

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 615 of file matrix.cpp.

References identity(), rotateX(), rotateY(), rotateZ(), NLMISC::CVector::x, XYZ, XZY, NLMISC::CVector::y, YXZ, YZX, NLMISC::CVector::z, ZXY, and ZYX.

Referenced by NL3D::CInstanceGroup::getInstanceMatrix(), NL3D::CWaterShape::getShapeInWorldSpace(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NL3D::CEvent3dMouseListener::operator()(), setRot(), NL3D::CPSFace::step(), and NL3D::ITransformable::updateMatrix().

void NLMISC::CMatrix::rotateX ( float  a  ) 

Apply a rotation on axis X to the matrix.

same as M=M*Rx

Parameters:
a angle (in radian).

Definition at line 495 of file matrix.cpp.

References a12, a13, a22, a23, a32, a33, a42, a43, hasProj(), hasRot(), MAT_ROT, StateBit, and testExpandRot().

Referenced by NL3D::CEvent3dMouseListener::operator()(), and rotate().

void NLMISC::CMatrix::rotateY ( float  a  ) 

Apply a rotation on axis Y to the matrix.

same as M=M*Ry

Parameters:
a angle (in radian).

Definition at line 535 of file matrix.cpp.

References a11, a13, a21, a23, a31, a33, a41, a43, hasProj(), hasRot(), MAT_ROT, StateBit, and testExpandRot().

Referenced by NL3D::ITransformable::lookAt(), NL3D::CComputedString::render2D(), and rotate().

void NLMISC::CMatrix::rotateZ ( float  a  ) 
void NLMISC::CMatrix::scale ( const CVector scale  ) 

Apply a non-uniform scale to the matrix.

Definition at line 666 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, a41, a42, a43, hasProj(), MAT_SCALEANY, scale(), StateBit, testExpandRot(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

void NLMISC::CMatrix::scale ( float  f  ) 
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 318 of file matrix.cpp.

References a14, a24, a34, a41, a42, a43, a44, M, MAT_IDENTITY, MAT_PROJ, MAT_ROT, MAT_SCALEANY, MAT_TRANS, MAT_VALIDPROJ, Scale33, and StateBit.

Referenced by NL3D::computeBoneMatrixes3x4(), NL3D::CDriverGL::getFrustumMatrix(), NL3D::CDriverD3D::getFrustumMatrix(), NL3D::CDriverGL::refreshProjMatrixFromGL(), and NL3D::CWaterModel::setupSimpleRender().

void NLMISC::CMatrix::setArbitraryRotI ( const CVector idir  ) 

Choose an arbitrary rotation matrix for the given direction.

The matrix will have I==idir

Parameters:
idir,: vector direction. MUST be normalized.

Definition at line 1538 of file matrix.cpp.

References NLMISC::CVector::I, NLMISC::CVector::J, NLMISC::CVector::K, normalize(), setRot(), XZY, and NLMISC::CVector::z.

void NLMISC::CMatrix::setArbitraryRotJ ( const CVector jdir  ) 

Choose an arbitrary rotation matrix for the given direction.

The matrix will have J==jdir

Parameters:
jdir,: vector direction. MUST be normalized.

Definition at line 1548 of file matrix.cpp.

References NLMISC::CVector::I, NLMISC::CVector::J, NLMISC::CVector::K, normalize(), setRot(), YZX, and NLMISC::CVector::z.

Referenced by NL3D::CShadowMap::buildCasterCameraMatrix().

void NLMISC::CMatrix::setArbitraryRotK ( const CVector kdir  ) 

Choose an arbitrary rotation matrix for the given direction.

The matrix will have K==kdir

Parameters:
kdir,: vector direction. MUST be normalized.

Definition at line 1558 of file matrix.cpp.

References NLMISC::CVector::I, NLMISC::CVector::J, NLMISC::CVector::K, normalize(), setRot(), NLMISC::CVector::y, and ZYX.

Referenced by NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CSkeletonModel::fastIntersect(), and NL3D::CRayMesh::fastIntersect().

void NLMISC::CMatrix::setCoefficient ( float  coeff,
sint  i,
sint  j 
) [inline]

Setup the (i, j) matrix coefficient.

Parameters:
coeff,: coefficient value.
i : column index.
j : line index.

Definition at line 173 of file matrix.h.

References M.

void NLMISC::CMatrix::setMulMatrix ( const CMatrix m1,
const CMatrix m2 
)

Matrix multiplication.

Because of copy avoidance, this is the fastest method Equivalent to *this= m1 * m2

Warning:
*this MUST NOT be the same as m1 or m2, else it doesn't work (not checked/nlasserted)

Definition at line 741 of file matrix.cpp.

References a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44, hasProj(), hasRot(), hasTrans(), identity(), MAT_PROJ, MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, MAT_TRANS, MAT_VALIDALL, MAT_VALIDPROJ, MAT_VALIDROT, nlassert, Scale33, StateBit, testExpandProj(), and testExpandRot().

Referenced by NL3D::CShadowMapProjector::applyToMaterial(), operator*(), and operator*=().

void NLMISC::CMatrix::setMulMatrixNoProj ( const CMatrix m1,
const CMatrix m2 
)

Matrix multiplication assuming no projection at all in m1/m2 and Hence this.

Even Faster than setMulMatrix() Equivalent to *this= m1 * m2 NB: Also always suppose m1 has a translation, for optimization consideration

Warning:
*this MUST NOT be the same as m1 or m2, else it doesn't work (not checked/nlasserted)

Definition at line 699 of file matrix.cpp.

References a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, hasScaleUniform(), MAT_PROJ, MAT_VALIDPROJ, MAT_VALIDROT, Scale33, StateBit, and testExpandRot().

Referenced by NL3D::CBone::compute(), and NL3D::computeBoneMatrixes3x4PreMul().

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 265 of file matrix.cpp.

References a14, a24, a34, MAT_TRANS, StateBit, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NLLIGO::CZoneTemplate::build(), NL3D::CCameraCol::build(), NLMISC::CPolygon::buildBasis(), NL3D::CPSZonePlane::buildBasis(), NLLIGO::CZoneEdge::buildMatrix(), NL3D::CPSConstraintMesh::CGlobalTexAnim::buildMatrix(), NL3D::CShadowMap::buildProjectionInfos(), NL3D::CCloud::calcBill(), NL3D::CLandscapeModel::clipAndRenderLandscape(), NL3D::CBone::compute(), NL3D::CShadowPolyReceiver::computeClippedTrisWithPolyClip(), NL3D::ComputeRibbonSliceFollowPath(), NL3D::ComputeRibbonSliceFollowPathXY(), NL3D::CMaterial::decompUserTexMat(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CWaterEnvMapRenderFromUScene::doRender(), NL3D::CLodCharacterManager::endRender(), NL3D::CSkeletonSpawnScript::evaluate(), NL3D::CSkeletonModel::fastIntersect(), NL3D::CRayMesh::fastIntersect(), NL3D::CCloud::genBill(), NL3D::CSkeletonModel::generateShadowMap(), NL3D::CMeshInstance::generateShadowMap(), NL3D::CPatch::generateTileVegetable(), NL3D::CPSZoneRectangle::getMatrix(), NL3D::CPSZoneCylinder::getMatrix(), NL3D::CPSCylindricVortex::getMatrix(), NL3D::CPSEmitterRectangle::getMatrix(), NL3D::CWaterModel::getNumWantedVertices(), NL3D::CViewport::getRayWithPoint(), NL3D::CEvent3dMouseListener::getViewMatrix(), InitZBuffer(), NL3D::CBone::interpolateBoneSkinMatrix(), NL3D::CInstanceLighter::light(), NL3D::CInstanceLighter::lightIgSimple(), NL3D::CZoneLighter::lightWater(), NL3D::ITransformable::lookAt(), NL3D::CEvent3dMouseListener::operator()(), NL3D::CPSUtil::print(), NL3D::CVisualCollisionMesh::receiveShadowMap(), NL3D::CVegetableManager::render(), NL3D::CSegRemanence::render(), NL3D::CCloudScape::render(), NL3D::CComputedString::render2D(), NL3D::CSkeletonModel::renderIntoSkeletonShadowMap(), NL3D::CMeshInstance::renderIntoSkeletonShadowMap(), NL3D::CShadowMapManager::renderProject(), NL3D::CShadowPolyReceiver::renderSelection(), NL3D::CDriverGL::setupModelMatrix(), NL3D::CLodCharacterManager::setupNormalCorrectionMatrix(), NL3D::CFlareModel::setupOcclusionMeshMatrix(), NL3D::CWaterModel::setupSimpleRender(), NL3D::CDriverGL::setupViewMatrix(), NL3D::CDriverD3D::setupViewMatrix(), NL3D::CDriverGL::setupViewMatrixEx(), NL3D::CVegetableBlendLayerModel::setWorldPos(), NL3D::CPSZoneRectangle::show(), NL3D::CPSZoneCylinder::show(), NL3D::CPSZoneDisc::show(), NL3D::CPSEmitterRectangle::showTool(), NL3D::CWaterModel::traverseRender(), NL3D::CAnimatedMaterial::update(), NLSOUND::CListenerFMod::updateFModPos(), and NL3D::CTransform::updateWorldMatrixFromFather().

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 289 of file matrix.cpp.

References a41, a42, a43, a44, MAT_PROJ, MAT_VALIDPROJ, and StateBit.

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.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, hasRot(), hasScaleUniform(), MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, MAT_VALIDROT, Scale33, and StateBit.

void NLMISC::CMatrix::setRot ( const CQuat quat  ) 

Explicit setup the Rotation matrix (base) as a Quaternion rotation matrix.

Parameters:
quat a UNIT quaternion

Definition at line 1346 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, NLMISC::CQuatT< T >::isIdentity(), MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, Scale33, StateBit, NLMISC::CQuatT< T >::w, NLMISC::CQuatT< T >::x, NLMISC::CQuatT< T >::y, and NLMISC::CQuatT< T >::z.

void NLMISC::CMatrix::setRot ( const CVector v,
TRotOrder  ro 
)

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.

References getRot(), identity(), rotate(), and setRot().

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, rotation, 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.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, Scale33, and StateBit.

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.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, Scale33, StateBit, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CCameraCol::build(), NLMISC::CPolygon::buildBasis(), NL3D::CShadowMap::buildCasterCameraMatrix(), NL3D::CPSConstraintMesh::CGlobalTexAnim::buildMatrix(), NL3D::CShadowMap::buildProjectionInfos(), NL3D::CPSUtil::buildSchmidtBasis(), NL3D::CCloud::calcBill(), NL3D::CCubeGrid< TCell >::CCubeGrid(), CTrackKeyFramerTCB< CKeyTCBQuat, NLMISC::CAngleAxis >::compile(), NL3D::ComputeRibbonSliceFollowPathXY(), NL3D::CShadowMapProjector::CShadowMapProjector(), NL3D::CMaterial::decompUserTexMat(), NL3D::CCloud::disp(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CSkeletonSpawnScript::evaluate(), NL3D::CTargetAnimCtrl::execute(), NL3D::CCloud::genBill(), NL3D::CVegetable::generateInstance(), NL3D::CPatch::generateTileVegetable(), NL3D::CPSZoneRectangle::getMatrix(), NL3D::CPSZoneCylinder::getMatrix(), NL3D::CPSEmitterRectangle::getMatrix(), NL3D::CBone::interpolateBoneSkinMatrix(), NL3D::CInstanceLighter::light(), NL3D::CInstanceLighter::lightIgSimple(), NL3D::CZoneLighter::lightWater(), NL3D::ITransformable::lookAt(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NEL3DCalcBase(), NL3D::NEL3DCalcBase(), NL3D::CWaterEnvMapRenderHelper::render(), NL3D::CSkeletonModel::renderIntoSkeletonShadowMap(), NL3D::CMeshInstance::renderIntoSkeletonShadowMap(), rotate(), NL3D::CQuadTree< T >::selectRay(), NL3D::CQuadTree< T >::selectSegment(), setArbitraryRotI(), setArbitraryRotJ(), setArbitraryRotK(), NL3D::CDriverUser::setMatrixMode2D(), NL3D::CCloud::setMode2D(), setRot(), NL3D::UTransformable::setRotQuat(), NL3D::CMeshVPWindTree::setupPerInstanceConstants(), NL3D::CPSRibbon::setupTextureMatrix(), NL3D::CPSShockWave::setupUFactor(), NL3D::CDriverGL::setupViewMatrix(), NL3D::CDriverGL::setupViewMatrixEx(), NL3D::CPSZoneRectangle::show(), NL3D::CPSZoneCylinder::show(), NL3D::CPSLight::show(), NL3D::CPSEmitterRectangle::showTool(), NL3D::CAnimatedMaterial::update(), NL3D::CWaterModel::updateDiffuseMapMatrix(), NLSOUND::CListenerFMod::updateFModPos(), NL3D::CPSMesh::updatePos(), and NL3D::CTransform::updateWorldMatrixFromFather().

void NLMISC::CMatrix::setScale ( const CVector v  ) 

Explicit setup the Rotation/Scale matrix (base) with a scale (=> matrix has no Rotation).

case where v.x==v.y==v.z is tested to set a uniform scale

Parameters:
scale the scale to set

Definition at line 1477 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, MAT_VALIDROT, setScaleUni(), StateBit, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

void NLMISC::CMatrix::setScale ( float  scale  ) 

Explicit setup the Rotation/Scale matrix (base) with a scale (=> matrix has no Rotation).

1 is tested to update bits accordingly

Parameters:
scale the scale to set

Definition at line 1470 of file matrix.cpp.

References setScaleUni().

Referenced by NL3D::CBone::compute().

void NLMISC::CMatrix::setScaleUni ( float  scale  )  [inline, private]

Definition at line 1458 of file matrix.cpp.

References a11, a12, a13, a21, a22, a23, a31, a32, a33, MAT_ROT, MAT_SCALEANY, MAT_SCALEUNI, MAT_VALIDROT, Scale33, and StateBit.

Referenced by setScale().

bool NLMISC::CMatrix::slowInvert33 ( CMatrix ret  )  const [private]

Definition at line 997 of file matrix.cpp.

References getI(), getJ(), getK(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by inverted().

bool NLMISC::CMatrix::slowInvert44 ( CMatrix ret  )  const [private]

Definition at line 1030 of file matrix.cpp.

References getCofactIndex(), and mat().

Referenced by inverted().

void NLMISC::CMatrix::testExpandProj (  )  const [inline, private]

Definition at line 147 of file matrix.cpp.

References hasProj(), MAT_VALIDPROJ, and StateBit.

Referenced by get(), inverted(), NLMISC::operator*(), operator*(), setMulMatrix(), and transpose().

void NLMISC::CMatrix::testExpandRot (  )  const [inline, private]
void NLMISC::CMatrix::translate ( const CVector v  ) 
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 932 of file matrix.cpp.

References a14, a24, a34, a41, a42, a43, hasProj(), hasTrans(), MAT_PROJ, MAT_TRANS, MAT_VALIDPROJ, StateBit, testExpandProj(), and transpose3x3().

Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CDriverD3D::getFrustumMatrix(), NL3D::CPSUtil::print(), NL3D::CDriverGL::setConstantMatrix(), and NL3D::CDriverD3D::setFrustumMatrix().

void NLMISC::CMatrix::transpose3x3 (  ) 

transpose the rotation part only of the matrix (swap columns/lines).

Definition at line 919 of file matrix.cpp.

References a12, a13, a21, a23, a31, a32, and hasRot().

Referenced by transpose().


Friends And Related Function Documentation

CPlane operator* ( const CPlane p,
const CMatrix m 
) [friend]

Plane (line vector) multiplication.


Member Data Documentation

float NLMISC::CMatrix::M[16] [private]

Definition at line 369 of file matrix.h.

Referenced by CMatrix(), get(), getPos(), mat(), operator=(), set(), and setCoefficient().


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

Generated on Thu Jan 7 08:30:18 2010 for NeL by  doxygen 1.6.1