OSG::TransformationMatrix< ValueTypeT > Class Template Reference
[BaseObjectslibOSGBase]

#include <OSGMatrix.h>

List of all members.

Public Types

Types



typedef TransformationMatrix
< ValueTypeT > 
Self
typedef ValueTypeT ValueType
 Value type, eg Real32.
typedef Vector< ValueTypeT, 4 > VectorType
 Matrix vector type, eg Vec4f.
typedef QuaternionBase< ValueTypeQuaternionType
 Matrix quaternion type.
typedef Vector< ValueTypeT, 3 > VectorType3f
 Matrix vec3f type.
typedef Point< ValueTypeT, 4 > PointType
typedef Point< ValueTypeT, 3 > PointType3f
 Matrix pnt3f type.

Public Member Functions

Constructors



 TransformationMatrix (void)
 TransformationMatrix (const TransformationMatrix &source)
 TransformationMatrix (const VectorType3f &vector1, const VectorType3f &vector2, const VectorType3f &vector3)
 TransformationMatrix (const VectorType &vector1, const VectorType &vector2, const VectorType &vector3, const VectorType &vector4)
 TransformationMatrix (const VectorType3f &vector1, const VectorType3f &vector2, const VectorType3f &vector3, const VectorType3f &vector4)
 TransformationMatrix (const ValueTypeT rVal00, const ValueTypeT rVal10, const ValueTypeT rVal20, const ValueTypeT rVal30, const ValueTypeT rVal01, const ValueTypeT rVal11, const ValueTypeT rVal21, const ValueTypeT rVal31, const ValueTypeT rVal02, const ValueTypeT rVal12, const ValueTypeT rVal22, const ValueTypeT rVal32, const ValueTypeT rVal03, const ValueTypeT rVal13, const ValueTypeT rVal23, const ValueTypeT rVal33)
Destructor



 ~TransformationMatrix (void)
Set



void setIdentity (void)
void setValue (const TransformationMatrix &mat)
template<class ValueTypeR >
void convertFrom (const TransformationMatrix< ValueTypeR > &mat)
void setValue (const VectorType3f &vector1, const VectorType3f &vector2, const VectorType3f &vector3)
void setValue (const VectorType3f &vector1, const VectorType3f &vector2, const VectorType3f &vector3, const VectorType3f &vector4)
void setValue (const ValueTypeT rVal00, const ValueTypeT rVal10, const ValueTypeT rVal20, const ValueTypeT rVal30, const ValueTypeT rVal01, const ValueTypeT rVal11, const ValueTypeT rVal21, const ValueTypeT rVal31, const ValueTypeT rVal02, const ValueTypeT rVal12, const ValueTypeT rVal22, const ValueTypeT rVal32, const ValueTypeT rVal03, const ValueTypeT rVal13, const ValueTypeT rVal23, const ValueTypeT rVal33)
void setValueTransposed (const ValueTypeT rVal00, const ValueTypeT rVal01, const ValueTypeT rVal02, const ValueTypeT rVal03, const ValueTypeT rVal10, const ValueTypeT rVal11, const ValueTypeT rVal12, const ValueTypeT rVal13, const ValueTypeT rVal20, const ValueTypeT rVal21, const ValueTypeT rVal22, const ValueTypeT rVal23, const ValueTypeT rVal30, const ValueTypeT rVal31, const ValueTypeT rVal32, const ValueTypeT rVal33)
void setValue (const ValueTypeT *pMat, bool bTransposed=true)
 Set value from an ValueTypeT array, be shure the sizes match.
void setValue (const VectorType *pMat)
 Set value from an VectorTypeT array, be shure the sizes match.
void setValue (const VectorType3f *pMat)
 Set value from an VectorType3f array, be shure the sizes match.
void setValue (const Char8 *string, bool bTransposed=true)
 Set matrix by a given str (like "1.0 0.0 0.0 0.0 ... (16 entries at all)"), be shure the size matches.
Get



ValueTypeT * getValues (void)
 Returns an C++ pointer to the value store.
const ValueTypeT * getValues (void) const
 Returns an C++ pointer to the value store.
Set Transformations



void setScale (const ValueTypeT s)
 Sets matrix to scale by given uniform factor.
void setScale (const ValueTypeT sx, const ValueTypeT sy, const ValueTypeT sz)
 Sets matrix to scale by given uniform factor.
void setScale (const VectorType3f &s)
 Sets matrix to scale by given vector.
void setTranslate (const ValueTypeT tx, const ValueTypeT ty, const ValueTypeT tz)
 Sets matrix to translate by given values.
void setTranslate (const VectorType3f &t)
 Sets matrix to translate by given vector.
void setTranslate (const PointType3f &t)
 Sets matrix to translate by given point.
void setRotate (const QuaternionType &q)
 Sets matrix to rotate by given rotation.
void setTransform (const VectorType3f &t)
 Composes the matrix based on a translation.
void setTransform (const QuaternionType &r)
 Composes the matrix based on a rotation.
void setTransform (const VectorType3f &t, const QuaternionType &r)
 Composes the matrix based on a translation and rotation.
void setTransform (const VectorType3f &t, const QuaternionType &r, const VectorType3f &s)
 Composes the matrix based on a translation, rotation and scale.
void setTransform (const VectorType3f &t, const QuaternionType &r, const VectorType3f &s, const QuaternionType &so)
 Composes the matrix based on a translation, rotation, scale and orientation.
void setTransform (const VectorType3f &translation, const QuaternionType &rotation, const VectorType3f &scaleFactor, const QuaternionType &scaleOrientation, const VectorType3f &center)
Get Transformations



void getTransform (VectorType3f &translation, QuaternionType &rotation, VectorType3f &scaleFactor, QuaternionType &scaleOrientation, const VectorType3f &center) const
 Decomposes the matrix into a translation, rotation, scale, and scale orientation. Any projection information is discarded. The decomposition depends upon choice of center point for rotation and scaling, which is optional as the last parameter. Note that if the center is 0, decompose() is the same as factor() where "t" is translation, "u" is rotation, "s" is scaleFactor, and "r" is ScaleOrientattion.
void getTransform (VectorType3f &translation, QuaternionType &rotation, VectorType3f &scaleFactor, QuaternionType &scaleOrientation) const
 Decomposes the matrix into a translation, rotation and scale.
bool factor (TransformationMatrix &r, VectorType3f &s, TransformationMatrix &u, VectorType3f &t, TransformationMatrix &proj) const
 Factors a matrix m into 5 pieces: m = r s rt u t, where rt means transpose of r, and r and u are rotations, s is a scale, and t is a translation. Any projection information is returned in proj.
Transform



void mult (const PointType &pntIn, PointType &pntOut) const
void multFull (const PointType3f &pntIn, PointType3f &pntOut) const
void mult (const PointType3f &pntIn, PointType3f &pntOut) const
void mult (const VectorType &vecIn, VectorType &vecOut) const
void multFull (const VectorType3f &vecIn, VectorType3f &vecOut) const
void mult (const VectorType3f &vecIn, VectorType3f &vecOut) const
void mult3x3 (const PointType3f &pntIn, PointType3f &pntOut) const
void mult3x3 (const VectorType3f &vecIn, VectorType3f &vecOut) const
void multLeftFull (const PointType3f &pntIn, PointType3f &pntOut) const
 Multiplies given row point by matrix, where the resulting point is given. The full (4x4) matrix is used (pT * M).
void multLeft (const PointType3f &pntIn, PointType3f &pntOut) const
 Multiplies given row point by matrix, where the resulting point is given (pT * M).
void multLeftFull (const VectorType3f &vecIn, VectorType3f &vecOut) const
void multLeft (const VectorType3f &vecIn, VectorType3f &vecOut) const
 Multiplies given row vector by matrix, where the resulting vector is given (vT * M).
PointType operator* (const PointType &pntIn) const
PointType3f operator* (const PointType3f &pntIn) const
VectorType operator* (const VectorType &vecIn) const
VectorType3f operator* (const VectorType3f &vecIn) const
Math



bool equals (const TransformationMatrix &matrix, const ValueType tol) const
 Returns true iff all matrix elements are equal within the given tolerance.
ValueTypeT det3 (void) const
 Returns the determinat of the upper 3x3 submatrix.
ValueTypeT det (void) const
 Returns the determinat of the whole 4x4 matrix.
bool inverse (TransformationMatrix &result) const
 Stores the inverse of the matrix into result, returns true if the matrix is not singular.
bool invert (void)
 Inverts the matrix, returns true if the matrix is not singular.
bool invertFrom (const TransformationMatrix &matrix)
 Set the matrix to be the inverse of the given one, returns true if the matrix is not singular.
bool inverse3 (TransformationMatrix &result) const
 Returns true iff all matrix elements are equal within the given tolerance.
bool invert3 (void)
 Returns true iff all matrix elements are equal within the given tolerance.
bool invertFrom3 (const TransformationMatrix &matrix)
 Returns true iff all matrix elements are equal within the given tolerance.
bool transposed (TransformationMatrix &result) const
 Returns true iff all matrix elements are equal within the given tolerance.
bool transpose (void)
 Returns true iff all matrix elements are equal within the given tolerance.
bool transposeFrom (const TransformationMatrix &matrix)
 Returns true iff all matrix elements are equal within the given tolerance.
template<class ValueTypeR >
void mult (const TransformationMatrix< ValueTypeR > &mat)
 Returns true iff all matrix elements are equal within the given tolerance.
template<class ValueTypeR >
void multLeft (const TransformationMatrix< ValueTypeR > &mat)
 Returns true iff all matrix elements are equal within the given tolerance.
void add (const TransformationMatrix &matrix)
 Adds the given matrix to this matrix.
void scale (ValueTypeT s)
 Scales the elements of this matrix.
void addScaled (const TransformationMatrix &matrix, ValueTypeT s)
 Adds a scaled version of the given matrix to this matrix.
void negate (void)
 Negates the matrix in place.
ValueTypeT norm1 (void) const
ValueTypeT norm2 (void) const
ValueTypeT normInfinity (void) const
bool sqrt (TransformationMatrix &result) const
 Computes the square root of the matrix and stores it in result, assumes det > 0.
bool sqrtOf (const TransformationMatrix &matrix)
 Sets this matrix to the square root of the given matrix, assumes det > 0.
bool sqrt (void)
 Sets this matrix to its square root, assumes det > 0.
bool log (TransformationMatrix &result) const
 Computes the logarithm of this matrix and stores it in result, assumes det > 0.
bool logOf (const TransformationMatrix &matrix)
 Sets this matrix to the logarithm of the given matrix, assumes det > 0.
bool exp (TransformationMatrix &result) const
 Computes the exponential of this matrix and stores it in result.
bool expOf (const TransformationMatrix &matrix)
 Sets this matrix to the exponential of the given matrix.
Element Access



VectorTypeoperator[] (UInt32 uiIndex)
const VectorTypeoperator[] (UInt32 uiIndex) const
Assignment



TransformationMatrixoperator= (const TransformationMatrix &source)
Comparison



bool operator== (const TransformationMatrix &other) const
 equal, returns true if all matrix elements are equal with the tolerance of Eps
bool operator!= (const TransformationMatrix &other) const
 not equal, returns true if all matrix elements are not equal with the tolerance of Eps

Static Public Member Functions

Class Get



static const TransformationMatrixidentity (void)

Protected Attributes

Storage



VectorType _matrix [4]
 Value store.

Static Private Attributes

static TransformationMatrix _identityMatrix

Related Functions

(Note that these are not member functions.)



Matrix Types



typedef
OSG::TransformationMatrix
< OSG::Real32 > 
Matrix4f
 Matrix4f.
typedef
OSG::TransformationMatrix
< OSG::Real64 > 
Matrix4d
 Matrix4d.
typedef
OSG::TransformationMatrix
< OSG::Fixed32
Matrix4fx
 Matrix4f.
typedef
OSG::TransformationMatrix
< OSG::Real32 > 
Matrix
 Matrix.
typedef
OSG::TransformationMatrix
< OSG::Fixed32
Matrixfx
 Matrixr.
Profile Matrix Types



typedef Matrix4f Matrixr
Matrix Functions

Matrix utility functions to create and analyze special kinds of matrices.



bool MatrixOrthogonal (OSG::Matrix &result, OSG::Real32 rLeft, OSG::Real32 rRight, OSG::Real32 rBottom, OSG::Real32 rTop, OSG::Real32 rNear, OSG::Real32 rFar)
bool MatrixFrustum (OSG::Matrixr &result, OSG::Real rLeft, OSG::Real rRight, OSG::Real rBottom, OSG::Real rTop, OSG::Real rNear, OSG::Real rFar)
bool MatrixPerspective (OSG::Matrixr &result, OSG::Real rFovy, OSG::Real rAspect, OSG::Real rNear, OSG::Real rFar)
bool MatrixStereoPerspective (OSG::Matrixr &projection, OSG::Matrixr &projtrans, OSG::Real rFovy, OSG::Real rAspect, OSG::Real rNear, OSG::Real rFfar, OSG::Real rZeroparallax, OSG::Real rEyedistance, OSG::Real rWhicheye, OSG::Real rOverlap)
bool MatrixLookAt (OSG::Matrix &result, OSG::Real32 fromx, OSG::Real32 fromy, OSG::Real32 fromz, OSG::Real32 atx, OSG::Real32 aty, OSG::Real32 atz, OSG::Real32 upx, OSG::Real32 upy, OSG::Real32 upz)
bool MatrixLookAt (OSG::Matrix &result, OSG::Pnt3f from, OSG::Pnt3f at, OSG::Vec3f up)
bool MatrixProjection (OSG::Matrix &result, OSG::Real32 rLeft, OSG::Real32 rRight, OSG::Real32 rBottom, OSG::Real32 rTop, OSG::Real32 rNear, OSG::Real32 rFar)

Internal Math



static const UInt32 JacobiRank = 3
template<class ValueTypeR , class ValueTypeS >
ValueTypeT rowMulCol4 (const TransformationMatrix< ValueTypeR > &gRowMat, UInt32 iRow, const TransformationMatrix< ValueTypeS > &gColMat, UInt32 iColumn) const
ValueTypeT det2_calc (const ValueTypeT a1, const ValueTypeT a2, const ValueTypeT b1, const ValueTypeT b2) const
ValueTypeT det3_calc (const ValueTypeT a1, const ValueTypeT a2, const ValueTypeT a3, const ValueTypeT b1, const ValueTypeT b2, const ValueTypeT b3, const ValueTypeT c1, const ValueTypeT c2, const ValueTypeT c3) const
bool calcInverse (TransformationMatrix *destM, const TransformationMatrix *srcM) const
bool calcInverse3 (TransformationMatrix *destM, const TransformationMatrix *srcM) const
ValueType norm1_3x3 (void) const
ValueType normInf_3x3 (void) const
void adjointT_3x3 (TransformationMatrix &result) const
void polarDecompose (TransformationMatrix &Q, TransformationMatrix &S, ValueType &det) const
void spectralDecompose (TransformationMatrix &SO, VectorType3f &k) const
void decompose (VectorType3f &t, ValueType &f, QuaternionType &r, QuaternionType &so, VectorType3f &s) const
bool jacobi (ValueTypeT evalues[JacobiRank], VectorType3f evectors[JacobiRank], Int32 &rots)

Detailed Description

template<class ValueTypeT>
class OSG::TransformationMatrix< ValueTypeT >

TransformationMatrix, for details about the vector, point and matrix desing see Math, nevertheless the following applies : M=(V0 V1 V2 V3), M[Column][Row], M[0] = V0 M[0][0] = V0[0] M.getValues() returns M transposed (as it returns the raw storage)

Definition at line 75 of file OSGMatrix.h.


Member Typedef Documentation

template<class ValueTypeT>
typedef TransformationMatrix<ValueTypeT> OSG::TransformationMatrix< ValueTypeT >::Self

Definition at line 85 of file OSGMatrix.h.

template<class ValueTypeT>
OSG::TransformationMatrix< ValueTypeT >::ValueType

Definition at line 87 of file OSGMatrix.h.

template<class ValueTypeT>
VectorInterface< ValueTypeT, VecStorage4< ValueTypeT > > OSG::TransformationMatrix< ValueTypeT >::VectorType

Definition at line 88 of file OSGMatrix.h.

template<class ValueTypeT>
QuaternionBase< ValueType > OSG::TransformationMatrix< ValueTypeT >::QuaternionType

Definition at line 90 of file OSGMatrix.h.

template<class ValueTypeT>
VectorInterface< ValueTypeT, VecStorage3< ValueTypeT > > OSG::TransformationMatrix< ValueTypeT >::VectorType3f

Definition at line 92 of file OSGMatrix.h.

template<class ValueTypeT>
typedef Point<ValueTypeT, 4> OSG::TransformationMatrix< ValueTypeT >::PointType

Definition at line 94 of file OSGMatrix.h.

template<class ValueTypeT>
PointInterface< ValueTypeT, VecStorage3< ValueTypeT > > OSG::TransformationMatrix< ValueTypeT >::PointType3f

Definition at line 95 of file OSGMatrix.h.


Constructor & Destructor Documentation

template<class ValueTypeT >
OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix ( void   )  [inline]

Definition at line 91 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

00092 {
00093     for(UInt32 i = 0; i < 4; i++)
00094     {
00095         _matrix[i][i] = TypeTraits<ValueType>::getOneElement();
00096     }
00097 }

template<class ValueTypeT >
OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix ( const TransformationMatrix< ValueTypeT > &  source  )  [inline]

Definition at line 100 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

00102 {
00103     for(UInt32 i = 0; i < 4; i++)
00104     {
00105         _matrix[i] = source._matrix[i];
00106     }
00107 }

template<class ValueTypeT >
OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix ( const VectorType3f vector1,
const VectorType3f vector2,
const VectorType3f vector3 
) [inline]

Definition at line 110 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00114 {
00115     _matrix[0].setValue(vector1);
00116     _matrix[1].setValue(vector2);
00117     _matrix[2].setValue(vector3);
00118
00119     _matrix[3][3] = TypeTraits<ValueType>::getOneElement();
00120 }

template<class ValueTypeT >
OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix ( const VectorType vector1,
const VectorType vector2,
const VectorType vector3,
const VectorType vector4 
) [inline]

Definition at line 123 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00128 {
00129     _matrix[0].setValue(vector1);
00130     _matrix[1].setValue(vector2);
00131     _matrix[2].setValue(vector3);
00132     _matrix[3].setValue(vector4);
00133 }

template<class ValueTypeT >
OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix ( const VectorType3f vector1,
const VectorType3f vector2,
const VectorType3f vector3,
const VectorType3f vector4 
) [inline]

Definition at line 136 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00141 {
00142     _matrix[0].setValue(vector1);
00143     _matrix[1].setValue(vector2);
00144     _matrix[2].setValue(vector3);
00145     _matrix[3].setValue(vector4);
00146 }

template<class ValueTypeT>
OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix ( const ValueTypeT  rVal00,
const ValueTypeT  rVal10,
const ValueTypeT  rVal20,
const ValueTypeT  rVal30,
const ValueTypeT  rVal01,
const ValueTypeT  rVal11,
const ValueTypeT  rVal21,
const ValueTypeT  rVal31,
const ValueTypeT  rVal02,
const ValueTypeT  rVal12,
const ValueTypeT  rVal22,
const ValueTypeT  rVal32,
const ValueTypeT  rVal03,
const ValueTypeT  rVal13,
const ValueTypeT  rVal23,
const ValueTypeT  rVal33 
) [inline]

Definition at line 149 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

00169 {
00170     _matrix[0].setValues(rVal00, rVal01, rVal02, rVal03);
00171     _matrix[1].setValues(rVal10, rVal11, rVal12, rVal13);
00172     _matrix[2].setValues(rVal20, rVal21, rVal22, rVal23);
00173     _matrix[3].setValues(rVal30, rVal31, rVal32, rVal33);
00174 }

template<class ValueTypeT >
OSG::TransformationMatrix< ValueTypeT >::~TransformationMatrix ( void   )  [inline]

Definition at line 180 of file OSGMatrix.inl.

00181 {
00182 }


Member Function Documentation

template<class ValueTypeT >
const TransformationMatrix< ValueTypeT > & OSG::TransformationMatrix< ValueTypeT >::identity ( void   )  [inline, static]

Definition at line 82 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_identityMatrix.

00083 {
00084     return _identityMatrix;
00085 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setIdentity ( void   )  [inline]

Definition at line 188 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setNull().

Referenced by OSG::LightChunk::activate(), OSG::ClipPlaneChunk::activate(), OSG::TransformationMatrix< ValueTypeT >::calcInverse(), OSG::TransformationMatrix< ValueTypeT >::calcInverse3(), OSG::DSLightChunk::calcModelView(), OSG::PerspectiveShadowMapHandler::calcPerspectiveSpot(), OSG::ClipPlaneChunk::changeFrom(), OSG::LightChunk::changeFrom(), OSG::DrawEnv::clearState(), OSG::SimpleShadowMapEngine::doFinalPass(), OSG::DrawEnv::DrawEnv(), OSG::TransformationMatrix< ValueTypeT >::exp(), OSG::TransformationMatrix< ValueTypeT >::expOf(), OSG::TransformationMatrix< ValueTypeT >::factor(), OSG::FlyEngine::FlyEngine(), OSG::FlyEngine::forward(), OSG::ShearedStereoCameraDecorator::getDecoration(), OSG::TileCameraDecorator::getDecoration(), OSG::Camera::getDecoration(), OSG::Trackball::getFullExamineMatrix(), OSG::Trackball::getFullTrackballMatrix(), OSG::ShearedStereoCameraDecorator::getProjection(), OSG::OffCenterPerspectiveCamera::getProjection(), OSG::ProjectionCameraDecorator::getProjection(), OSG::TileCameraDecorator::getProjection(), OSG::PerspectiveCamera::getProjection(), OSG::OrthographicCamera::getProjection(), OSG::MatrixCameraDecorator::getProjection(), OSG::CameraDecorator::getProjection(), OSG::Camera::getProjectionTranslation(), OSG::CameraDecorator::getProjectionTranslation(), OSG::ProjectionCameraDecorator::getProjectionTranslation(), OSG::MatrixCameraDecorator::getProjectionTranslation(), OSG::Node::getToWorld(), OSG::ProjectionCameraDecorator::getViewing(), OSG::MatrixCameraDecorator::getViewing(), OSG::CameraDecorator::getViewing(), OSG::Node::getWorldVolume(), OSG::PerspectiveShadowMapHandler::render(), OSG::DisplayFilterStage::renderEnter(), OSG::AlgorithmStage::renderEnter(), OSG::HDRStage::renderEnter(), OSG::FishEyeProjector::renderEnter(), OSG::RenderPartition::reset(), OSG::Manipulator::reverseTransform(), OSG::FlyEngine::right(), OSG::FlyEngine::rotate(), OSG::TransformationMatrix< ValueTypeT >::setTransform(), OSG::SimpleShadowMapEngine::setupCamera(), OSG::ShadowTreeHandler::setupDrawCombineMap1(), OSG::ShadowTreeHandler::setupDrawCombineMap2(), OSG::DeferredShadingStage::setupShadingPartition(), OSG::RenderPartition::setupViewing(), OSG::TransformationMatrix< ValueTypeT >::setValue(), OSG::TransformationMatrix< ValueTypeT >::sqrt(), OSG::TransformationMatrix< ValueTypeT >::sqrtOf(), OSG::TrackballEngine::TrackballEngine(), OSG::TrackballEngine::translateXY(), OSG::Navigator::updateCameraTransformation(), OSG::TrackballEngine::updateFinalMatrix(), and OSG::ShadowStage::updateLights().

00189 {
00190     for(UInt32 i = 0; i < 4; i++)
00191     {
00192         _matrix[i].setNull();
00193         _matrix[i][i] = TypeTraits<ValueType>::getOneElement();
00194     }
00195 }

template<class ValueTypeT >
template<class ValueTypeR >
void OSG::TransformationMatrix< ValueTypeT >::convertFrom ( const TransformationMatrix< ValueTypeR > &  mat  )  [inline]

Definition at line 210 of file OSGMatrix.inl.

Referenced by OSG::DoubleTransform::adjustVolume(), OSG::RenderPartition::dropFunctor(), OSG::DoubleTransform::intersectEnter(), OSG::DoubleTransform::intersectLeave(), and OSG::RenderPartition::setupViewing().

00212 {
00213     for(UInt32 i = 0; i < 4; i++)
00214     {
00215         for(UInt32 j =0; j<4; j++)
00216         {
00217            (*this)[i][j] = mat[i][j];
00218         }
00219     }
00220 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const VectorType3f vector1,
const VectorType3f vector2,
const VectorType3f vector3 
) [inline]

Definition at line 224 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00227 {
00228     _matrix[0].setValue(vector1);
00229     _matrix[1].setValue(vector2);
00230     _matrix[2].setValue(vector3);
00231 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const VectorType3f vector1,
const VectorType3f vector2,
const VectorType3f vector3,
const VectorType3f vector4 
) [inline]

Definition at line 234 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00238 {
00239     _matrix[0].setValue(vector1);
00240     _matrix[1].setValue(vector2);
00241     _matrix[2].setValue(vector3);
00242     _matrix[3].setValue(vector4);
00243 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const ValueTypeT  rVal00,
const ValueTypeT  rVal10,
const ValueTypeT  rVal20,
const ValueTypeT  rVal30,
const ValueTypeT  rVal01,
const ValueTypeT  rVal11,
const ValueTypeT  rVal21,
const ValueTypeT  rVal31,
const ValueTypeT  rVal02,
const ValueTypeT  rVal12,
const ValueTypeT  rVal22,
const ValueTypeT  rVal32,
const ValueTypeT  rVal03,
const ValueTypeT  rVal13,
const ValueTypeT  rVal23,
const ValueTypeT  rVal33 
) [inline]

Definition at line 246 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

00265 {
00266     _matrix[0].setValues(rVal00, rVal01, rVal02, rVal03);
00267     _matrix[1].setValues(rVal10, rVal11, rVal12, rVal13);
00268     _matrix[2].setValues(rVal20, rVal21, rVal22, rVal23);
00269     _matrix[3].setValues(rVal30, rVal31, rVal32, rVal33);
00270 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setValueTransposed ( const ValueTypeT  rVal00,
const ValueTypeT  rVal01,
const ValueTypeT  rVal02,
const ValueTypeT  rVal03,
const ValueTypeT  rVal10,
const ValueTypeT  rVal11,
const ValueTypeT  rVal12,
const ValueTypeT  rVal13,
const ValueTypeT  rVal20,
const ValueTypeT  rVal21,
const ValueTypeT  rVal22,
const ValueTypeT  rVal23,
const ValueTypeT  rVal30,
const ValueTypeT  rVal31,
const ValueTypeT  rVal32,
const ValueTypeT  rVal33 
) [inline]

Definition at line 273 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::PerspectiveShadowMapHandler::scaleTranslateToFit2(), OSG::TransformationMatrix< ValueTypeT >::setValue(), OSG::TransformationMatrix< ValueTypeT >::transposed(), and OSG::TransformationMatrix< ValueTypeT >::transposeFrom().

00293 {
00294     _matrix[0].setValues(rVal00, rVal01, rVal02, rVal03);
00295     _matrix[1].setValues(rVal10, rVal11, rVal12, rVal13);
00296     _matrix[2].setValues(rVal20, rVal21, rVal22, rVal23);
00297     _matrix[3].setValues(rVal30, rVal31, rVal32, rVal33);
00298 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const ValueTypeT *  pMat,
bool  bTransposed = true 
) [inline]

Definition at line 303 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00305 {
00306     const ValueTypeT *pTmpMat = pMat;
00307
00308     if(bTransposed == true)
00309     {
00310         for(UInt32 i = 0; i < 4; i++)
00311         {
00312             _matrix[i].setValue(pTmpMat);
00313
00314             pTmpMat += 4;
00315         }
00316     }
00317     else
00318     {
00319         for(UInt32 i = 0; i < 4; i++)
00320         {
00321             for(UInt32 j = 0; j < 4; j++)
00322             {
00323                 _matrix[i][j] = pTmpMat[j * 4 + i];
00324             }
00325         }
00326     }
00327 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const VectorType pMat  )  [inline]

Definition at line 332 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

00333 {
00334     for(UInt32 i = 0; i < 4; i++)
00335     {
00336         _matrix[i] = pMat[i];
00337     }
00338 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const VectorType3f pMat  )  [inline]

Definition at line 343 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::setValue().

00344 {
00345     for(UInt32 i = 0; i < 4; i++)
00346     {
00347         _matrix[i].setValue(pMat[i]);
00348     }
00349 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setValue ( const Char8 *  string,
bool  bTransposed = true 
) [inline]

Definition at line 356 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::setIdentity(), OSG::TransformationMatrix< ValueTypeT >::setValue(), and OSG::TransformationMatrix< ValueTypeT >::setValueTransposed().

00358 {
00359     UInt32 i;
00360     UInt32 numOfToken = 16;
00361
00362     Char8 *c = const_cast<char*>(str);
00363
00364     Char8 *tokenC = 0;
00365     Char8  token[256];
00366
00367     ValueTypeT vec[16];
00368
00369     if( (str  == NULL) ||
00370         (*str == '\0') )
00371     {
00372         setIdentity();
00373         return;
00374     }
00375
00376     for(i = 0; i < numOfToken; c++)
00377     {
00378         switch (*c)
00379         {
00380             case '\0':
00381                 if (tokenC)
00382                 {
00383                     *tokenC   = 0;
00384                      vec[i++] = TypeTraits<ValueTypeT>::getFromCString(token);
00385
00386                 }
00387
00388                 while (i < numOfToken)
00389                 {
00390                     vec[i++] = TypeTraits<ValueTypeT>::getZeroElement();
00391                 }
00392
00393                 break;
00394             case ' ':
00395             case '\t':
00396             case '\n':
00397             case ',':
00398                 if (tokenC)
00399                 {
00400                     *tokenC   = 0;
00401                      vec[i++] = TypeTraits<ValueTypeT>::getFromCString(token);
00402                      tokenC   = 0;
00403                 }
00404                 break;
00405             default:
00406                 if (!tokenC)
00407                 {
00408                     tokenC = token;
00409                 }
00410                 *tokenC++ = *c;
00411                 break;
00412         }
00413     }
00414
00415     if(bTransposed == true)
00416     {
00417         setValueTransposed(vec[0],  vec[1],  vec[2],  vec[3],
00418                            vec[4],  vec[5],  vec[6],  vec[7],
00419                            vec[8],  vec[9],  vec[10], vec[11],
00420                            vec[12], vec[13], vec[14], vec[15]);
00421     }
00422     else
00423     {
00424         setValue(vec[0],  vec[1],  vec[2],  vec[3],
00425                  vec[4],  vec[5],  vec[6],  vec[7],
00426                  vec[8],  vec[9],  vec[10], vec[11],
00427                  vec[12], vec[13], vec[14], vec[15]);
00428     }
00429 }

template<class ValueTypeT >
const ValueTypeT * OSG::TransformationMatrix< ValueTypeT >::getValues ( void   )  const [inline]

Definition at line 443 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::getValues().

00444 {
00445     return _matrix[0].getValues();
00446 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setScale ( const ValueTypeT  s  )  [inline]
template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setScale ( const ValueTypeT  sx,
const ValueTypeT  sy,
const ValueTypeT  sz 
) [inline]

Definition at line 1001 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01004 {
01005     _matrix[0][0] = sx;
01006     _matrix[1][1] = sy;
01007     _matrix[2][2] = sz;
01008 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setScale ( const VectorType3f s  )  [inline]

Definition at line 1013 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01014 {
01015     _matrix[0][0] = s[0];
01016     _matrix[1][1] = s[1];
01017     _matrix[2][2] = s[2];
01018 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setTranslate ( const VectorType3f t  )  [inline]
template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::setTranslate ( const PointType3f t  )  [inline]
template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setTransform ( const VectorType3f t  )  [inline]
template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setTransform ( const QuaternionType r  )  [inline]

Definition at line 1072 of file OSGMatrix.inl.

References OSG::QuaternionBase< ValueTypeT >::getValue().

01073 {
01074     // Calculate the 4x4 rotation matrix
01075     r.getValue(*this);
01076 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setTransform ( const VectorType3f t,
const QuaternionType r 
) [inline]

Definition at line 1081 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::QuaternionBase< ValueTypeT >::getValuesOnly().

01083 {
01084     r.getValuesOnly(*this);
01085
01086     // Calculate the resulting transformation matrix
01087     _matrix[0][3] = 0.0;
01088     _matrix[1][3] = 0.0;
01089     _matrix[2][3] = 0.0;
01090
01091     _matrix[3][0] = t[0];
01092     _matrix[3][1] = t[1];
01093     _matrix[3][2] = t[2];
01094     _matrix[3][3] = 1.0;
01095 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setTransform ( const VectorType3f t,
const QuaternionType r,
const VectorType3f s 
) [inline]

Definition at line 1100 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::QuaternionBase< ValueTypeT >::getValuesOnly().

01103 {
01104     typedef TypeTraits<ValueTypeT> ValueTraits;
01105
01106     // Calculate the 3x3 rotation matrix
01107     r.getValuesOnly(*this);
01108
01109     // Calculate the resulting transformation matrix
01110     _matrix[0][0] *= s[0]; _matrix[0][1] *= s[0]; _matrix[0][2] *=s[0];
01111     _matrix[1][0] *= s[1]; _matrix[1][1] *= s[1]; _matrix[1][2] *=s[1];
01112     _matrix[2][0] *= s[2]; _matrix[2][1] *= s[2]; _matrix[2][2] *=s[2];
01113
01114     _matrix[0][3] = ValueTraits::getZeroElement();
01115     _matrix[1][3] = ValueTraits::getZeroElement();
01116     _matrix[2][3] = ValueTraits::getZeroElement();
01117
01118     _matrix[3][0] = t[0];
01119     _matrix[3][1] = t[1];
01120     _matrix[3][2] = t[2];
01121     _matrix[3][3] = ValueTraits::getOneElement();
01122 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setTransform ( const VectorType3f t,
const QuaternionType r,
const VectorType3f s,
const QuaternionType so 
) [inline]

Definition at line 1127 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, OSG::QuaternionBase< ValueTypeT >::getValue(), OSG::QuaternionBase< ValueTypeT >::invert(), and OSG::QuaternionBase< ValueTypeT >::mult().

01131 {
01132     TransformationMatrix<ValueTypeT> tmpMat1;
01133     TransformationMatrix<ValueTypeT> tmpMat2;
01134
01135     // Concatenate the rotations r and so
01136     QuaternionType rg(r);
01137     rg.mult(so);
01138
01139     // Calculate the inverse of so
01140     QuaternionType soi(so);
01141     soi.invert();
01142
01143     // Calculate the 3x3 rotation matrix
01144     rg. getValue(tmpMat1);
01145     soi.getValue(tmpMat2);
01146
01147     // Calculate the resulting transformation matrix
01148     tmpMat1[0][0] *= s[0]; tmpMat1[0][1] *= s[0]; tmpMat1[0][2] *=s[0];
01149     tmpMat1[1][0] *= s[1]; tmpMat1[1][1] *= s[1]; tmpMat1[1][2] *=s[1];
01150     tmpMat1[2][0] *= s[2]; tmpMat1[2][1] *= s[2]; tmpMat1[2][2] *=s[2];
01151
01152     _matrix[0][0] =
01153         tmpMat2[0][0] * tmpMat1[0][0] +
01154         tmpMat2[0][1] * tmpMat1[1][0] +
01155         tmpMat2[0][2] * tmpMat1[2][0];
01156
01157     _matrix[0][1] =
01158         tmpMat2[0][0] * tmpMat1[0][1] +
01159         tmpMat2[0][1] * tmpMat1[1][1] +
01160         tmpMat2[0][2] * tmpMat1[2][1];
01161
01162     _matrix[0][2] =
01163         tmpMat2[0][0] * tmpMat1[0][2] +
01164         tmpMat2[0][1] * tmpMat1[1][2] +
01165         tmpMat2[0][2] * tmpMat1[2][2];
01166
01167     _matrix[0][3] = 0.0;
01168
01169
01170     _matrix[1][0] =
01171         tmpMat2[1][0] * tmpMat1[0][0] +
01172         tmpMat2[1][1] * tmpMat1[1][0] +
01173         tmpMat2[1][2] * tmpMat1[2][0];
01174
01175     _matrix[1][1] =
01176         tmpMat2[1][0] * tmpMat1[0][1] +
01177         tmpMat2[1][1] * tmpMat1[1][1] +
01178         tmpMat2[1][2] * tmpMat1[2][1];
01179
01180     _matrix[1][2] =
01181         tmpMat2[1][0] * tmpMat1[0][2] +
01182         tmpMat2[1][1] * tmpMat1[1][2] +
01183         tmpMat2[1][2] * tmpMat1[2][2];
01184
01185     _matrix[1][3] = 0.0;
01186
01187
01188     _matrix[2][0] =
01189         tmpMat2[2][0] * tmpMat1[0][0] +
01190         tmpMat2[2][1] * tmpMat1[1][0] +
01191         tmpMat2[2][2] * tmpMat1[2][0];
01192
01193     _matrix[2][1] =
01194         tmpMat2[2][0] * tmpMat1[0][1] +
01195         tmpMat2[2][1] * tmpMat1[1][1] +
01196         tmpMat2[2][2] * tmpMat1[2][1];
01197
01198     _matrix[2][2] =
01199         tmpMat2[2][0] * tmpMat1[0][2] +
01200         tmpMat2[2][1] * tmpMat1[1][2] +
01201         tmpMat2[2][2] * tmpMat1[2][2];
01202
01203     _matrix[2][3] = 0.0;
01204
01205     _matrix[3][0] = t[0];
01206     _matrix[3][1] = t[1];
01207     _matrix[3][2] = t[2];
01208     _matrix[3][3] = 1.0;
01209 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::setTransform ( const VectorType3f translation,
const QuaternionType rotation,
const VectorType3f scaleFactor,
const QuaternionType scaleOrientation,
const VectorType3f center 
) [inline]

Composes the matrix based on a translation, rotation, scale, orientation for scale, and center. The "center" is the center point for scaling and rotation. The "scaleOrientation" chooses the primary axes for the scale.

Definition at line 1218 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, OSG::QuaternionBase< ValueTypeT >::getValue(), and OSG::QuaternionBase< ValueTypeT >::invert().

01224 {
01225     typedef TypeTraits<ValueTypeT> ValueTraits;
01226
01227     TransformationMatrix<ValueTypeT> tmpMat1;
01228     TransformationMatrix<ValueTypeT> tmpMat2;
01229
01230     // Concatenate the translations t and c
01231     VectorType3f tg(translation);
01232     tg += center;
01233
01234     // Concatenate the rotations r and so
01235     QuaternionType rg(rotation);
01236     rg *= scaleOrientation;
01237
01238     // Calculate the inverse of so
01239     QuaternionType soi(scaleOrientation);
01240     soi.invert();
01241
01242     // Calculate the 3x3 rotation matrix
01243     rg. getValue(tmpMat1);
01244     soi.getValue(tmpMat2);
01245
01246     // Calculate the resulting transformation matrix
01247
01248     tmpMat1[0][0] *= scaleFactor[0];
01249     tmpMat1[0][1] *= scaleFactor[0];
01250     tmpMat1[0][2] *= scaleFactor[0];
01251
01252     tmpMat1[1][0] *= scaleFactor[1];
01253     tmpMat1[1][1] *= scaleFactor[1];
01254     tmpMat1[1][2] *= scaleFactor[1];
01255
01256     tmpMat1[2][0] *= scaleFactor[2];
01257     tmpMat1[2][1] *= scaleFactor[2];
01258     tmpMat1[2][2] *= scaleFactor[2];
01259
01260     _matrix[0][0] =
01261         tmpMat2[0][0] * tmpMat1[0][0] +
01262         tmpMat2[0][1] * tmpMat1[1][0] +
01263         tmpMat2[0][2] * tmpMat1[2][0];
01264
01265     _matrix[0][1] =
01266         tmpMat2[0][0] * tmpMat1[0][1] +
01267         tmpMat2[0][1] * tmpMat1[1][1] +
01268         tmpMat2[0][2] * tmpMat1[2][1];
01269
01270     _matrix[0][2] =
01271         tmpMat2[0][0] * tmpMat1[0][2] +
01272         tmpMat2[0][1] * tmpMat1[1][2] +
01273         tmpMat2[0][2] * tmpMat1[2][2];
01274
01275     _matrix[0][3] = ValueTraits::getZeroElement();
01276
01277
01278     _matrix[1][0] =
01279         tmpMat2[1][0] * tmpMat1[0][0] +
01280         tmpMat2[1][1] * tmpMat1[1][0] +
01281         tmpMat2[1][2] * tmpMat1[2][0];
01282
01283     _matrix[1][1] =
01284         tmpMat2[1][0] * tmpMat1[0][1] +
01285         tmpMat2[1][1] * tmpMat1[1][1] +
01286         tmpMat2[1][2] * tmpMat1[2][1];
01287
01288     _matrix[1][2] =
01289         tmpMat2[1][0] * tmpMat1[0][2] +
01290         tmpMat2[1][1] * tmpMat1[1][2] +
01291         tmpMat2[1][2] * tmpMat1[2][2];
01292
01293     _matrix[1][3] = ValueTraits::getZeroElement();
01294
01295
01296     _matrix[2][0] =
01297         tmpMat2[2][0] * tmpMat1[0][0] +
01298         tmpMat2[2][1] * tmpMat1[1][0] +
01299         tmpMat2[2][2] * tmpMat1[2][0];
01300
01301     _matrix[2][1] =
01302         tmpMat2[2][0] * tmpMat1[0][1] +
01303         tmpMat2[2][1] * tmpMat1[1][1] +
01304         tmpMat2[2][2] * tmpMat1[2][1];
01305
01306     _matrix[2][2] =
01307         tmpMat2[2][0] * tmpMat1[0][2] +
01308         tmpMat2[2][1] * tmpMat1[1][2] +
01309         tmpMat2[2][2] * tmpMat1[2][2];
01310
01311     _matrix[2][3] = ValueTraits::getZeroElement();
01312
01313
01314     _matrix[3][0] =
01315         _matrix[0][0] * -center[0] +
01316         _matrix[1][0] * -center[1] +
01317         _matrix[2][0] * -center[2] + tg[0];
01318
01319     _matrix[3][1] =
01320         _matrix[0][1] * -center[0] +
01321         _matrix[1][1] * -center[1] +
01322         _matrix[2][1] * -center[2] + tg[1];
01323
01324     _matrix[3][2] =
01325         _matrix[0][2] * -center[0] +
01326         _matrix[1][2] * -center[1] +
01327         _matrix[2][2] * -center[2] + tg[2];
01328
01329     _matrix[3][3] = ValueTraits::getOneElement();
01330
01331 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::getTransform ( VectorType3f translation,
QuaternionType rotation,
VectorType3f scaleFactor,
QuaternionType scaleOrientation,
const VectorType3f center 
) const [inline]

Definition at line 1346 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::getTransform(), OSG::TransformationMatrix< ValueTypeT >::mult(), and OSG::TransformationMatrix< ValueTypeT >::setTranslate().

Referenced by OSG::CSMTrackball::changed(), OSG::TransformationMatrix< ValueTypeT >::getTransform(), OSG::Manipulator::mouseMove(), OSG::Manipulator::reverseTransform(), and OSG::VRMLWriteAction::writeTransformEnter().

01352 {
01353     TransformationMatrix m;
01354     TransformationMatrix c;
01355
01356     m.setTranslate(-center);
01357
01358     m.mult(*this);
01359
01360     c.setTranslate(center);
01361
01362     m.mult(c);
01363
01364     m.getTransform(translation, rotation, scaleFactor, scaleOrientation);
01365 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::getTransform ( VectorType3f translation,
QuaternionType rotation,
VectorType3f scaleFactor,
QuaternionType scaleOrientation 
) const [inline]

Definition at line 1370 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::decompose().

01375 {
01376     ValueType            flip;
01377     TransformationMatrix so;
01378     TransformationMatrix rot;
01379     TransformationMatrix proj;
01380
01381     this->decompose(translation, flip, rotation, scaleOrientation, scaleFactor);
01382
01383     scaleFactor *= flip;
01384 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::factor ( TransformationMatrix< ValueTypeT > &  r,
VectorType3f s,
TransformationMatrix< ValueTypeT > &  u,
VectorType3f t,
TransformationMatrix< ValueTypeT > &  proj 
) const [inline]
Bug:
This function seems to be BROKEN.

Definition at line 1395 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, OSG::TransformationMatrix< ValueTypeT >::det(), OSG::TransformationMatrix< ValueTypeT >::det3(), OSG::TransformationMatrix< ValueTypeT >::jacobi(), OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::osgSqrt(), OSG::TransformationMatrix< ValueTypeT >::setIdentity(), OSG::TransformationMatrix< ValueTypeT >::setValue(), and OSG::TransformationMatrix< ValueTypeT >::transposeFrom().

01400 {
01401     Real64               det;
01402     Real64               det_sign;
01403     Real64               scratch;
01404     Int32                i;
01405     Int32                j;
01406     Int32                junk;
01407     TransformationMatrix a;
01408     TransformationMatrix aT;
01409     TransformationMatrix rT;
01410     TransformationMatrix b;
01411     TransformationMatrix si;
01412     ValueTypeT           evalues [3];
01413     VectorType3f         evectors[3];
01414
01415     a = *this;
01416
01417     proj.setIdentity();
01418
01419     scratch = 1.0;
01420
01421     for (i = 0; i < 3; i++)
01422     {
01423         for (j = 0; j < 3; j++)
01424         {
01425             a._matrix[i][j] *= ValueTypeT(scratch);
01426         }
01427
01428         t[i] = _matrix[3][i] * ValueTypeT(scratch);
01429
01430         a._matrix[3][i] = a._matrix[i][3] = 0.0;
01431     }
01432
01433     a._matrix[3][3] = 1.0;
01434
01435     /* (3) Compute det A. If negative, set sign = -1, else sign = 1 */
01436
01437     det      = a.det3();
01438
01439     det_sign = (det < 0.0 ? -1.0 : 1.0);
01440
01441     if(det_sign * det < 1e-12)
01442         return false;      // singular
01443
01444     /* (4) B = A * A^  (here A^ means A transpose) */
01445
01446     aT.transposeFrom(a);
01447     b = a;
01448     b.mult(aT);
01449
01450     b.jacobi(evalues, evectors, junk);
01451
01452     r.setValue(evectors[0][0], evectors[0][1], evectors[0][2], 0.0,
01453                evectors[1][0], evectors[1][1], evectors[1][2], 0.0,
01454                evectors[2][0], evectors[2][1], evectors[2][2], 0.0,
01455                           0.0,            0.0,            0.0, 1.0);
01456
01457     /* Compute s = sqrt(evalues), with sign. Set si = s-inverse */
01458
01459     si.setIdentity();
01460
01461     for(i = 0; i < 3; i++)
01462     {
01463         s[i] = ValueTypeT(det_sign * osgSqrt(evalues[i]));
01464
01465         si._matrix[i][i] = 1.0f / s[i];
01466     }
01467
01468     /* (5) Compute U = RT S! R A. */
01469
01470     rT.transposeFrom(r);
01471     u = r;
01472     u.mult(si);
01473     u.mult(rT);
01474     u.mult(a);
01475
01476     return true;
01477 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::mult ( const PointType pntIn,
PointType pntOut 
) const [inline]

Multiply the point pIn by this complete 4x4 matrix and store the result in pntOut.

Note:
The resulting point can have a w coordinate different from 1.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.

Multiply the 3 point pntIn by this matrix (considering only the 3x4 part) and store the result in pntOut.

Note:
pntIn is treated as having w = 1.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.

Definition at line 1489 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::Transform::accumulateMatrix(), OSG::InverseTransform::accumulateMatrix(), OSG::ScreenGroup::accumulateMatrix(), OSG::DoubleTransform::accumulateMatrix(), OSG::Billboard::accumulateMatrix(), OSG::LightChunk::activate(), OSG::ClipPlaneChunk::activate(), OSG::TrackballEngine::calcDeltas(), OSG::ShaderShadowMapEngine::calcDirectionalLightMatrices(), OSG::RenderPartition::calcFrustum(), OSG::Particles::calcIndex(), OSG::ScreenGroup::calcMatrix(), OSG::Billboard::calcMatrix(), OSG::DSLightChunk::calcModelView(), OSG::PerspectiveShadowMapHandler::calcPerspectiveSpot(), OSG::ShaderShadowMapEngine::calcPointLightMatrices(), OSG::Manipulator::calcScreenProjection(), OSG::ShaderShadowMapEngine::calcSpotLightMatrices(), OSG::TrapezoidalShadowMapEngine::calcTrapezoidalTransform(), OSG::Camera::calcViewRay(), OSG::ClipPlaneChunk::changeFrom(), OSG::LightChunk::changeFrom(), OSG::ShadowStage::checkLightsOcclusion(), OSG::SkyBackground::clear(), OSG::BalancedMultiWindow::createBBoxes(), OSG::PerspectiveShadowMapHandler::createShadowFactorMapFBO(), OSG::PCSSShadowMapHandler::createShadowFactorMapFBO(), OSG::StdShadowMapHandler::createShadowFactorMapFBO(), OSG::PCFShadowMapHandler::createShadowFactorMapFBO(), OSG::DitherShadowMapHandler::createShadowFactorMapFBO(), OSG::VarianceShadowMapHandler::createShadowFactorMapFBO(), OSG::VarianceShadowMapHandler::createShadowMapsFBO(), OSG::SimpleShadowMapEngine::doFinalPass(), OSG::Particles::drawPrimitives(), OSG::TransformationMatrix< ValueTypeT >::exp(), OSG::TransformationMatrix< ValueTypeT >::expOf(), OSG::TransformationMatrix< ValueTypeT >::factor(), OSG::FlyEngine::forward(), OSG::Camera::getFrustum(), OSG::Trackball::getFullExamineMatrix(), OSG::Trackball::getFullTrackballMatrix(), OSG::ShearedStereoCameraDecorator::getProjection(), OSG::ProjectionCameraDecorator::getProjection(), OSG::MatrixCameraDecorator::getProjection(), OSG::ProjectionCameraDecorator::getProjectionTranslation(), OSG::MatrixCameraDecorator::getProjectionTranslation(), OSG::TransformationMatrix< ValueTypeT >::getTransform(), OSG::MatrixCameraDecorator::getViewing(), OSG::Camera::getWorldToScreen(), OSG::ShaderShadowMapEngine::handleDirectionalLightEnter(), OSG::Transform::intersectEnter(), OSG::Billboard::intersectEnter(), OSG::ScreenGroup::intersectEnter(), OSG::InverseTransform::intersectEnter(), OSG::DoubleTransform::intersectEnter(), OSG::DoubleTransform::intersectLeave(), OSG::Transform::intersectLeave(), OSG::ScreenGroup::intersectLeave(), OSG::Billboard::intersectLeave(), OSG::InverseTransform::intersectLeave(), OSG::TransformationMatrix< ValueTypeT >::log(), OSG::TransformationMatrix< ValueTypeT >::logOf(), myCalcCCtoWCMatrix(), OSG::TransformationMatrix< ValueTypeT >::operator*(), OSG::TransformationMatrix< ValueTypeT >::polarDecompose(), OSG::MergeGraphOp::processTransformations(), OSG::TransformPushGraphOp::pushToGeometry(), OSG::ScreenLOD::renderEnter(), OSG::FishEyeProjector::renderEnter(), OSG::FlyEngine::right(), OSG::TrackballEngine::rotate(), OSG::SimpleShadowMapEngine::setupCamera(), OSG::DrawEnv::setupProjection(), OSG::DeferredShadingStage::setupShadingPartition(), OSG::DrawEnv::setupViewing(), OSG::OcclusionCullingTreeBuilder::testNode(), OSG::Plane::transform(), OSG::SphereVolume::transform(), OSG::CylinderVolume::transform(), OSG::TrackballEngine::translateXY(), OSG::Navigator::updateCameraTransformation(), OSG::TrackballEngine::updateFinalMatrix(), OSG::ShadowStage::updateLights(), OSG::RenderPartition::updateModelMatrix(), OSG::Trackball::updatePosition(), OSG::Trackball::updatePositionNeg(), OSG::TreeBuilderBase::updateTopMatrix(), and OSG::OBJSceneFileType::write().

01491 {
01492     pntOut.setValues(
01493         (_matrix[0][0] * pntIn[0] +
01494          _matrix[1][0] * pntIn[1] +
01495          _matrix[2][0] * pntIn[2] +
01496          _matrix[3][0] * pntIn[3]  ),
01497         (_matrix[0][1] * pntIn[0] +
01498          _matrix[1][1] * pntIn[1] +
01499          _matrix[2][1] * pntIn[2] +
01500          _matrix[3][1] * pntIn[3]  ),
01501         (_matrix[0][2] * pntIn[0] +
01502          _matrix[1][2] * pntIn[1] +
01503          _matrix[2][2] * pntIn[2] +
01504          _matrix[3][2] * pntIn[3]  ),
01505         (_matrix[0][3] * pntIn[0] +
01506          _matrix[1][3] * pntIn[1] +
01507          _matrix[2][3] * pntIn[2] +
01508          _matrix[3][3] * pntIn[3]  ) );
01509 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::multFull ( const PointType3f pntIn,
PointType3f pntOut 
) const [inline]

Multiply the 3 point pntIn by this complete 4x4 matrix and store the result in pntOut.

Note:
Both pntIn and pntOut are treated as having w = 1 and pntOut is scaled correctly to satisfy this.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.

Definition at line 1520 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and FWARNING.

Referenced by OSG::PerspectiveShadowMapHandler::bbInsideFrustum(), OSG::TrackballEngine::calcDeltas(), OSG::PerspectiveShadowMapHandler::calcHull2(), OSG::ScreenGroup::calcMatrix(), OSG::PerspectiveShadowMapHandler::calcPerspectiveSpot(), OSG::Manipulator::calcScreenProjection(), OSG::TrapezoidalShadowMapEngine::calcTrapezoidalTransform(), OSG::Camera::calcViewRay(), OSG::TrackballEngine::getIntersectionPoint(), OSG::ImageComposer::getScreenAlignedBBox(), OSG::Transform::intersectEnter(), OSG::Billboard::intersectEnter(), OSG::ScreenGroup::intersectEnter(), OSG::InverseTransform::intersectEnter(), OSG::DoubleTransform::intersectEnter(), OSG::DoubleTransform::intersectLeave(), OSG::Transform::intersectLeave(), OSG::ScreenGroup::intersectLeave(), OSG::Billboard::intersectLeave(), OSG::InverseTransform::intersectLeave(), OSG::MergeGraphOp::processTransformations(), OSG::TransformPushGraphOp::pushToGeometry(), OSG::ScreenLOD::renderEnter(), OSG::OcclusionCullingTreeBuilder::testNode(), and OSG::TileGeometryLoad::updateView().

01522 {
01523     ValueType w = _matrix[0][3] * pntIn[0] +
01524                   _matrix[1][3] * pntIn[1] +
01525                   _matrix[2][3] * pntIn[2] +
01526                   _matrix[3][3];
01527
01528     if(w == TypeTraits<ValueType>::getZeroElement())
01529     {
01530         FWARNING(("TransformationMatrix<>::multFull(Pnt3, Pnt3): w == 0.0\n"));
01531
01532         pntOut.setValues(
01533             (_matrix[0][0] * pntIn[0] +
01534              _matrix[1][0] * pntIn[1] +
01535              _matrix[2][0] * pntIn[2] +
01536              _matrix[3][0]             ),
01537             (_matrix[0][1] * pntIn[0] +
01538              _matrix[1][1] * pntIn[1] +
01539              _matrix[2][1] * pntIn[2] +
01540              _matrix[3][1]             ),
01541             (_matrix[0][2] * pntIn[0] +
01542              _matrix[1][2] * pntIn[1] +
01543              _matrix[2][2] * pntIn[2] +
01544              _matrix[3][2]             ) );
01545     }
01546     else
01547     {
01548         w = TypeTraits<ValueType>::getOneElement() / w;
01549
01550         pntOut.setValues(
01551             (_matrix[0][0] * pntIn[0] +
01552              _matrix[1][0] * pntIn[1] +
01553              _matrix[2][0] * pntIn[2] +
01554              _matrix[3][0]             ) * w,
01555             (_matrix[0][1] * pntIn[0] +
01556              _matrix[1][1] * pntIn[1] +
01557              _matrix[2][1] * pntIn[2] +
01558              _matrix[3][1]             ) * w,
01559             (_matrix[0][2] * pntIn[0] +
01560              _matrix[1][2] * pntIn[1] +
01561              _matrix[2][2] * pntIn[2] +
01562              _matrix[3][2]             ) * w );
01563     }
01564 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::mult ( const PointType3f pntIn,
PointType3f pntOut 
) const

Multiply the point pIn by this complete 4x4 matrix and store the result in pntOut.

Note:
The resulting point can have a w coordinate different from 1.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.

Multiply the 3 point pntIn by this matrix (considering only the 3x4 part) and store the result in pntOut.

Note:
pntIn is treated as having w = 1.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.
template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::mult ( const VectorType vecIn,
VectorType vecOut 
) const [inline]

Multiply the vector vecIn by this complete 4x4 matrix and store the result in vecOut.

Note:
The resulting vector can have a w coordinate different from 0.
It is valid for parameters to be aliased, i.e. &vecIn == &vecOut.

Definition at line 1601 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01603 {
01604     vecOut.setValues(
01605         (_matrix[0][0] * vecIn[0] +
01606          _matrix[1][0] * vecIn[1] +
01607          _matrix[2][0] * vecIn[2] +
01608          _matrix[3][0] * vecIn[3]  ),
01609         (_matrix[0][1] * vecIn[0] +
01610          _matrix[1][1] * vecIn[1] +
01611          _matrix[2][1] * vecIn[2] +
01612          _matrix[3][1] * vecIn[3]  ),
01613         (_matrix[0][2] * vecIn[0] +
01614          _matrix[1][2] * vecIn[1] +
01615          _matrix[2][2] * vecIn[2] +
01616          _matrix[3][2] * vecIn[3]  ),
01617         (_matrix[0][3] * vecIn[0] +
01618          _matrix[1][3] * vecIn[1] +
01619          _matrix[2][3] * vecIn[2] +
01620          _matrix[3][3] * vecIn[3]  ) );
01621 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::multFull ( const VectorType3f vecIn,
VectorType3f vecOut 
) const [inline]

Multiply the 3 vector vecIn by this complete 4x4 matrix and store the result in vecOut.

Note:
Both vecIn and vecOut are treated as having w = 0, so actually only the 4x3 part of this matrix is applied.
It is valid for parameters to be aliased, i.e. &vecIn == &vecOut.

Definition at line 1632 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and FWARNING.

01634 {
01635     ValueType w = _matrix[0][3] * vecIn[0] +
01636                   _matrix[1][3] * vecIn[1] +
01637                   _matrix[2][3] * vecIn[2];
01638
01639     if(w == TypeTraits<ValueType>::getZeroElement())
01640     {
01641         FWARNING(("TransformationMatrix<>::multFull(Vec3, Vec3): w == 0.0\n"));
01642
01643         vecOut.setValues(
01644             (_matrix[0][0] * vecIn[0] +
01645              _matrix[1][0] * vecIn[1] +
01646              _matrix[2][0] * vecIn[2]  ),
01647             (_matrix[0][1] * vecIn[0] +
01648              _matrix[1][1] * vecIn[1] +
01649              _matrix[2][1] * vecIn[2]  ),
01650             (_matrix[0][2] * vecIn[0] +
01651              _matrix[1][2] * vecIn[1] +
01652              _matrix[2][2] * vecIn[2]  ) );
01653     }
01654     else
01655     {
01656         w = TypeTraits<ValueType>::getOneElement() / w;
01657
01658         vecOut.setValues(
01659             (_matrix[0][0] * vecIn[0] +
01660              _matrix[1][0] * vecIn[1] +
01661              _matrix[2][0] * vecIn[2]  ) * w,
01662             (_matrix[0][1] * vecIn[0] +
01663              _matrix[1][1] * vecIn[1] +
01664              _matrix[2][1] * vecIn[2]  ) * w,
01665             (_matrix[0][2] * vecIn[0] +
01666              _matrix[1][2] * vecIn[1] +
01667              _matrix[2][2] * vecIn[2]  ) * w );
01668     }
01669 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::mult ( const VectorType3f vecIn,
VectorType3f vecOut 
) const [inline]

Multiply the 3 vector vecIn by this matrix (considering only the 3x4 part) and store the result in vecOut.

Note:
vecIn is treated as having w = 0, so actually only the 3x3 part of this matrix is applied.
It is valid for parameters to be aliased, i.e. &vecIn == &vecOut.

Definition at line 1680 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01682 {
01683     vecOut.setValues(
01684         (_matrix[0][0] * vecIn[0] +
01685          _matrix[1][0] * vecIn[1] +
01686          _matrix[2][0] * vecIn[2]  ),
01687         (_matrix[0][1] * vecIn[0] +
01688          _matrix[1][1] * vecIn[1] +
01689          _matrix[2][1] * vecIn[2]  ),
01690         (_matrix[0][2] * vecIn[0] +
01691          _matrix[1][2] * vecIn[1] +
01692          _matrix[2][2] * vecIn[2]  ) );
01693 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::mult3x3 ( const PointType3f pntIn,
PointType3f pntOut 
) const [inline]

Multiply the 3 point pntIn by the 3x3 part of this matrix and store the result in pntOut.

Note:
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.

Definition at line 1702 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01704 {
01705     pntOut.setValues(
01706         (_matrix[0][0] * pntIn[0] +
01707          _matrix[1][0] * pntIn[1] +
01708          _matrix[2][0] * pntIn[2]  ),
01709         (_matrix[0][1] * pntIn[0] +
01710          _matrix[1][1] * pntIn[1] +
01711          _matrix[2][1] * pntIn[2]  ),
01712         (_matrix[0][2] * pntIn[0] +
01713          _matrix[1][2] * pntIn[1] +
01714          _matrix[2][2] * pntIn[2]  ) );
01715 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::mult3x3 ( const VectorType3f vecIn,
VectorType3f vecOut 
) const [inline]

Multiply the 3 vector vecIn by the 3x3 part of this matrix and store the result in vecOut.

Note:
It is valid for parameters to be aliased, i.e. &vecIn == &vecOut.

Definition at line 1724 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01726 {
01727     vecOut.setValues(
01728         (_matrix[0][0] * vecIn[0] +
01729          _matrix[1][0] * vecIn[1] +
01730          _matrix[2][0] * vecIn[2]  ),
01731         (_matrix[0][1] * vecIn[0] +
01732          _matrix[1][1] * vecIn[1] +
01733          _matrix[2][1] * vecIn[2]  ),
01734         (_matrix[0][2] * vecIn[0] +
01735          _matrix[1][2] * vecIn[1] +
01736          _matrix[2][2] * vecIn[2]  ) );
01737 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::multLeftFull ( const PointType3f pntIn,
PointType3f pntOut 
) const [inline]

Definition at line 1767 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and FWARNING.

01770 {
01771     ValueTypeT w =  src[0] * _matrix[3][0] +
01772                     src[1] * _matrix[3][1] +
01773                     src[2] * _matrix[3][2] +
01774                              _matrix[3][3];
01775
01776     if(w == TypeTraits<ValueTypeT>::getZeroElement())
01777     {
01778         FWARNING(("TransformationMatrix<>::multLeftFull(Pnt3, Pnt3): "
01779                   "w == 0.0!\n"));
01780
01781         dst.setValues(0, 0, 0);
01782
01783         return;
01784     }
01785
01786     w = 1./w;
01787
01788     dst.setValues((src[0] * _matrix[0][0] +
01789                    src[1] * _matrix[0][1] +
01790                    src[2] * _matrix[0][2] +
01791                             _matrix[0][3]) * w,
01792                   (src[0] * _matrix[1][0] +
01793                    src[1] * _matrix[1][1] +
01794                    src[2] * _matrix[1][2] +
01795                             _matrix[1][3]) * w,
01796                   (src[0] * _matrix[2][0] +
01797                    src[1] * _matrix[2][1] +
01798                    src[2] * _matrix[2][2] +
01799                             _matrix[2][3]) * w);
01800 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::multLeft ( const PointType3f pntIn,
PointType3f pntOut 
) const [inline]

Definition at line 1744 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::Particles::calcIndex(), OSG::PerspectiveShadowMapHandler::calcPerspectiveSpot(), OSG::BalancedMultiWindow::calculateProjectedBBox(), changeGenFunc(), OSG::SkyBackground::clear(), OSG::RotateManipulator::doMovement(), OSG::ScaleManipulator::doMovement(), OSG::MoveManipulator::doMovement(), OSG::QuadTreeTerrain::doRenderEnter(), OSG::TiledQuadTreeTerrain::doRenderEnter(), drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::draw(), drawViewerQuads< posTrait, colTrait, texTrait, sizeTrait >::draw(), drawViewerObjects< posTrait, colTrait, sizeTrait, geoTrait >::draw(), drawViewerObjects< posTrait, colTrait, sizeTrait, geoTrait >::drawIndexed(), drawViewerQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed(), drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed(), OSG::TransformationMatrix< ValueTypeT >::exp(), OSG::TransformationMatrix< ValueTypeT >::expOf(), OSG::TileCameraDecorator::getDecoration(), OSG::TileCameraDecorator::getProjection(), OSG::MatrixCameraDecorator::getProjection(), OSG::MatrixCameraDecorator::getProjectionTranslation(), OSG::ImageComposer::getScreenAlignedBBox(), OSG::MatrixCameraDecorator::getViewing(), OSG::TrapezoidalShadowMapEngine::handlePointLightEnter(), OSG::ShaderShadowMapEngine::handlePointLightEnter(), OSG::TrapezoidalShadowMapEngine::handleSpotLightEnter(), OSG::TransformPushGraphOp::pushToTransform(), OSG::FishEyeProjector::renderEnter(), OSG::Manipulator::reverseTransform(), setGenFunc(), and OSG::TileGeometryLoad::updateView().

01747 {
01748     dst.setValues((src[0] * _matrix[0][0] +
01749                    src[1] * _matrix[0][1] +
01750                    src[2] * _matrix[0][2] +
01751                             _matrix[0][3]),
01752                   (src[0] * _matrix[1][0] +
01753                    src[1] * _matrix[1][1] +
01754                    src[2] * _matrix[1][2] +
01755                             _matrix[1][3]),
01756                   (src[0] * _matrix[2][0] +
01757                    src[1] * _matrix[2][1] +
01758                    src[2] * _matrix[2][2] +
01759                             _matrix[2][3]));
01760 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::multLeftFull ( const VectorType3f vecIn,
VectorType3f vecOut 
) const [inline]

Multiply the 3 vector vecIn by this complete 4x4 matrix and store the result in vecOut.

Note:
Both vecIn and vecOut are treated as having w = 0, so actually only the 4x3 part of this matrix is applied.
It is valid for parameters to be aliased, i.e. &vecIn == &vecOut.

Definition at line 1811 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and FWARNING.

01813 {
01814     ValueType w = _matrix[3][0] * vecIn[0] +
01815                   _matrix[3][1] * vecIn[1] +
01816                   _matrix[3][2] * vecIn[2];
01817
01818     if(w == TypeTraits<ValueType>::getZeroElement())
01819     {
01820         FWARNING(("TransformationMatrix<>::multLeftFull(Vec3, Vec3): "
01821                   "w == 0.0\n"));
01822
01823         vecOut.setValues(
01824             (_matrix[0][0] * vecIn[0] +
01825              _matrix[0][1] * vecIn[1] +
01826              _matrix[0][2] * vecIn[2]  ),
01827             (_matrix[1][0] * vecIn[0] +
01828              _matrix[1][1] * vecIn[1] +
01829              _matrix[1][2] * vecIn[2]  ),
01830             (_matrix[2][0] * vecIn[0] +
01831              _matrix[2][1] * vecIn[1] +
01832              _matrix[2][2] * vecIn[2]  ) );
01833     }
01834     else
01835     {
01836         w = TypeTraits<ValueType>::getOneElement() / w;
01837
01838         vecOut.setValues(
01839             (_matrix[0][0] * vecIn[0] +
01840              _matrix[0][1] * vecIn[1] +
01841              _matrix[0][2] * vecIn[2]  ) * w,
01842             (_matrix[1][0] * vecIn[0] +
01843              _matrix[1][1] * vecIn[1] +
01844              _matrix[1][2] * vecIn[2]  ) * w,
01845             (_matrix[2][0] * vecIn[0] +
01846              _matrix[2][1] * vecIn[1] +
01847              _matrix[2][2] * vecIn[2]  ) * w );
01848     }
01849 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::multLeft ( const VectorType3f vecIn,
VectorType3f vecOut 
) const [inline]

Definition at line 1856 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

01859 {
01860     dst.setValues((src[0] * _matrix[0][0] +
01861                    src[1] * _matrix[0][1] +
01862                    src[2] * _matrix[0][2]),
01863                   (src[0] * _matrix[1][0] +
01864                    src[1] * _matrix[1][1] +
01865                    src[2] * _matrix[1][2]),
01866                   (src[0] * _matrix[2][0] +
01867                    src[1] * _matrix[2][1] +
01868                    src[2] * _matrix[2][2]));
01869 }

template<class ValueTypeT >
TransformationMatrix< ValueTypeT >::PointType3f OSG::TransformationMatrix< ValueTypeT >::operator* ( const PointType pntIn  )  const [inline]

Multiply the point pntIn by this complete 4x4 matrix and return the result.

Note:
The resulting point can have a w coordinate different from 1.

Multiply the 3 point pntIn by this matrix (considering only the 3x4 part) and return the result.

Note:
pntIn is treated as having w = 1.

Definition at line 1880 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::mult().

01882 {
01883     PointType pntOut;
01884
01885     this->mult(pntIn, pntOut);
01886
01887     return pntOut;
01888 }

template<class ValueTypeT>
PointType3f OSG::TransformationMatrix< ValueTypeT >::operator* ( const PointType3f pntIn  )  const

Multiply the point pIn by this complete 4x4 matrix and store the result in pntOut.

Note:
The resulting point can have a w coordinate different from 1.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.

Multiply the 3 point pntIn by this matrix (considering only the 3x4 part) and store the result in pntOut.

Note:
pntIn is treated as having w = 1.
It is valid for parameters to be aliased, i.e. &pntIn == &pntOut.
template<class ValueTypeT >
TransformationMatrix< ValueTypeT >::VectorType OSG::TransformationMatrix< ValueTypeT >::operator* ( const VectorType vecIn  )  const [inline]

Multiply the vector vecIn by this complete 4x4 matrix and return the result.

Note:
The resulting vector can have a w coordinate different from 1.

Definition at line 1914 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::mult().

01916 {
01917     VectorType vecOut;
01918
01919     this->mult(vecIn, vecOut);
01920
01921     return vecOut;
01922 }

template<class ValueTypeT >
TransformationMatrix< ValueTypeT >::VectorType3f OSG::TransformationMatrix< ValueTypeT >::operator* ( const VectorType3f vecIn  )  const [inline]

Multiply the 3 vector vecIn by this matrix (considering only the 3x4 part) and return the result.

Note:
vecIn is treated as having w = 0, so actually only the 3x3 part of this matrix is applied.

Definition at line 1932 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::mult().

01934 {
01935     VectorType3f vecOut;
01936
01937     this->mult(vecIn, vecOut);
01938
01939     return vecOut;
01940 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::equals ( const TransformationMatrix< ValueTypeT > &  matrix,
const ValueType  tol 
) const [inline]

Definition at line 1949 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::Point< ValueTypeT, SizeI >::equals().

Referenced by OSG::ScreenGroup::calcMatrix(), OSG::TransformChunk::operator==(), and OSG::TransformationMatrix< ValueTypeT >::operator==().

01952 {
01953     UInt32 i;
01954     bool returnValue = true;
01955
01956     for(i = 0; i < 4; i++)
01957     {
01958         returnValue &= _matrix[i].equals(matrix._matrix[i], tolerance);
01959
01960         if(returnValue == false)
01961             break;
01962     }
01963
01964     return returnValue;
01965 }

template<class ValueTypeT >
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::det3 ( void   )  const [inline]

Definition at line 1970 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::TransformationMatrix< ValueTypeT >::calcInverse3(), and OSG::TransformationMatrix< ValueTypeT >::factor().

01971 {
01972     return (_matrix[0][0] * _matrix[1][1] * _matrix[2][2] +
01973             _matrix[0][1] * _matrix[1][2] * _matrix[2][0] +
01974             _matrix[0][2] * _matrix[1][0] * _matrix[2][1] -
01975             _matrix[0][2] * _matrix[1][1] * _matrix[2][0] -
01976             _matrix[0][1] * _matrix[1][0] * _matrix[2][2] -
01977             _matrix[0][0] * _matrix[1][2] * _matrix[2][1]);
01978 }

template<class ValueTypeT >
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::det ( void   )  const [inline]

Definition at line 1983 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::TransformationMatrix< ValueTypeT >::det3_calc().

Referenced by OSG::TransformationMatrix< ValueTypeT >::decompose(), OSG::TransformationMatrix< ValueTypeT >::factor(), OSG::TransformationMatrix< ValueTypeT >::sqrt(), and OSG::TransformationMatrix< ValueTypeT >::sqrtOf().

01984 {
01985     ValueTypeT
01986         a1, a2, a3, a4,
01987         b1, b2, b3, b4,
01988         c1, c2, c3, c4,
01989         d1, d2, d3, d4;
01990
01991     a1 = _matrix[0][0];
01992     b1 = _matrix[1][0];
01993     c1 = _matrix[2][0];
01994     d1 = _matrix[3][0];
01995
01996     a2 = _matrix[0][1];
01997     b2 = _matrix[1][1];
01998     c2 = _matrix[2][1];
01999     d2 = _matrix[3][1];
02000
02001     a3 = _matrix[0][2];
02002     b3 = _matrix[1][2];
02003     c3 = _matrix[2][2];
02004     d3 = _matrix[3][2];
02005
02006     a4 = _matrix[0][3];
02007     b4 = _matrix[1][3];
02008     c4 = _matrix[2][3];
02009     d4 = _matrix[3][3];
02010
02011     return(   a1 * det3_calc(b2, b3, b4, c2, c3, c4, d2, d3, d4)
02012             - b1 * det3_calc(a2, a3, a4, c2, c3, c4, d2, d3, d4)
02013             + c1 * det3_calc(a2, a3, a4, b2, b3, b4, d2, d3, d4)
02014             - d1 * det3_calc(a2, a3, a4, b2, b3, b4, c2, c3, c4));
02015
02016 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::inverse ( TransformationMatrix< ValueTypeT > &  result  )  const [inline]
template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::invert ( void   )  [inline]

Definition at line 2034 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::calcInverse().

Referenced by OSG::PerspectiveShadowMapHandler::bbInsideFrustum(), OSG::TrackballEngine::calcDeltas(), OSG::ShaderShadowMapEngine::calcDirectionalLightMatrices(), OSG::Particles::calcIndex(), OSG::PerspectiveShadowMapHandler::calcPerspectiveSpot(), OSG::ShaderShadowMapEngine::calcPointLightMatrices(), OSG::ShaderShadowMapEngine::calcSpotLightMatrices(), OSG::PerspectiveShadowMapHandler::createShadowFactorMapFBO(), OSG::PCSSShadowMapHandler::createShadowFactorMapFBO(), OSG::PCFShadowMapHandler::createShadowFactorMapFBO(), OSG::DitherShadowMapHandler::createShadowFactorMapFBO(), OSG::StdShadowMapHandler::createShadowFactorMapFBO(), OSG::VarianceShadowMapHandler::createShadowFactorMapFBO(), OSG::TiledQuadTreeTerrain::doRenderEnter(), OSG::QuadTreeTerrain::doRenderEnter(), drawViewerQuads< posTrait, colTrait, texTrait, sizeTrait >::draw(), drawViewerObjects< posTrait, colTrait, sizeTrait, geoTrait >::draw(), drawViewerObjects< posTrait, colTrait, sizeTrait, geoTrait >::drawIndexed(), drawViewerQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed(), OSG::Particles::drawPrimitives(), OSG::ShaderVariableOSG::evaluate(), OSG::ProjectionCameraDecorator::getProjection(), OSG::ProjectionCameraDecorator::getProjectionTranslation(), OSG::MatrixCamera::getViewing(), OSG::ProjectionCameraDecorator::getViewing(), OSG::Camera::getViewing(), OSG::Transform::intersectEnter(), OSG::Billboard::intersectEnter(), OSG::ScreenGroup::intersectEnter(), OSG::InverseTransform::intersectEnter(), OSG::DoubleTransform::intersectEnter(), OSG::RenderPartition::pushVisibility(), OSG::CubeMapGenerator::renderEnter(), OSG::FishEyeProjector::renderEnter(), OSG::SimpleShadowMapEngine::setupCamera(), and OSG::ShadowStage::updateLights().

02035 {
02036     TransformationMatrix thisCopy = *this;
02037
02038     return calcInverse(this, &thisCopy);
02039 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::inverse3 ( TransformationMatrix< ValueTypeT > &  result  )  const [inline]

Definition at line 2053 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::calcInverse3().

02055 {
02056     return calcInverse3(&result, this);
02057 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::invert3 ( void   )  [inline]

Definition at line 2060 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::calcInverse3().

02061 {
02062     TransformationMatrix thisCopy = *this;
02063
02064     return calcInverse3(this, &thisCopy);
02065 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::invertFrom3 ( const TransformationMatrix< ValueTypeT > &  matrix  )  [inline]

Definition at line 2068 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::calcInverse3().

02070 {
02071     return calcInverse3(this, &matrix);
02072 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::transposed ( TransformationMatrix< ValueTypeT > &  result  )  const [inline]

Definition at line 2075 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::setValueTransposed().

02077 {
02078     result.setValueTransposed(
02079         (*this)[0][0], (*this)[1][0], (*this)[2][0], (*this)[3][0],
02080         (*this)[0][1], (*this)[1][1], (*this)[2][1], (*this)[3][1],
02081         (*this)[0][2], (*this)[1][2], (*this)[2][2], (*this)[3][2],
02082         (*this)[0][3], (*this)[1][3], (*this)[2][3], (*this)[3][3]);
02083
02084     return true;
02085 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::transpose ( void   )  [inline]

Definition at line 2088 of file OSGMatrix.inl.

Referenced by OSG::SimpleShadowMapEngine::doFinalPass(), drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::draw(), drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed(), OSG::ShaderVariableOSG::evaluate(), and OSG::TransformationMatrix< ValueTypeT >::polarDecompose().

02089 {
02090     ValueTypeT tmp;
02091
02092     tmp = (*this)[1][0]; (*this)[1][0] = (*this)[0][1]; (*this)[0][1] = tmp;
02093     tmp = (*this)[2][0]; (*this)[2][0] = (*this)[0][2]; (*this)[0][2] = tmp;
02094     tmp = (*this)[3][0]; (*this)[3][0] = (*this)[0][3]; (*this)[0][3] = tmp;
02095     tmp = (*this)[2][1]; (*this)[2][1] = (*this)[1][2]; (*this)[1][2] = tmp;
02096     tmp = (*this)[3][1]; (*this)[3][1] = (*this)[1][3]; (*this)[1][3] = tmp;
02097     tmp = (*this)[3][2]; (*this)[3][2] = (*this)[2][3]; (*this)[2][3] = tmp;
02098
02099     return true;
02100 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::transposeFrom ( const TransformationMatrix< ValueTypeT > &  matrix  )  [inline]

Definition at line 2103 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::setValueTransposed().

Referenced by OSG::TransformationMatrix< ValueTypeT >::factor(), and OSG::TransformationMatrix< ValueTypeT >::polarDecompose().

02105 {
02106     this->setValueTransposed(
02107         matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
02108         matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
02109         matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
02110         matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
02111
02112     return true;
02113 }

template<class ValueTypeT >
template<class ValueTypeR >
void OSG::TransformationMatrix< ValueTypeT >::mult ( const TransformationMatrix< ValueTypeR > &  mat  )  [inline]

Definition at line 2117 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::TransformationMatrix< ValueTypeT >::rowMulCol4().

02118 {
02119     ValueTypeT rTmpMat[4][4];
02120
02121     (rTmpMat)[0][0] = rowMulCol4((*this), 0, (matrix), 0);
02122     (rTmpMat)[0][1] = rowMulCol4((*this), 1, (matrix), 0);
02123     (rTmpMat)[0][2] = rowMulCol4((*this), 2, (matrix), 0);
02124     (rTmpMat)[0][3] = rowMulCol4((*this), 3, (matrix), 0);
02125
02126     (rTmpMat)[1][0] = rowMulCol4((*this), 0, (matrix), 1);
02127     (rTmpMat)[1][1] = rowMulCol4((*this), 1, (matrix), 1);
02128     (rTmpMat)[1][2] = rowMulCol4((*this), 2, (matrix), 1);
02129     (rTmpMat)[1][3] = rowMulCol4((*this), 3, (matrix), 1);
02130
02131     (rTmpMat)[2][0] = rowMulCol4((*this), 0, (matrix), 2);
02132     (rTmpMat)[2][1] = rowMulCol4((*this), 1, (matrix), 2);
02133     (rTmpMat)[2][2] = rowMulCol4((*this), 2, (matrix), 2);
02134     (rTmpMat)[2][3] = rowMulCol4((*this), 3, (matrix), 2);
02135
02136     (rTmpMat)[3][0] = rowMulCol4((*this), 0, (matrix), 3);
02137     (rTmpMat)[3][1] = rowMulCol4((*this), 1, (matrix), 3);
02138     (rTmpMat)[3][2] = rowMulCol4((*this), 2, (matrix), 3);
02139     (rTmpMat)[3][3] = rowMulCol4((*this), 3, (matrix), 3);
02140
02141     _matrix[0][0] = rTmpMat[0][0];
02142     _matrix[0][1] = rTmpMat[0][1];
02143     _matrix[0][2] = rTmpMat[0][2];
02144     _matrix[0][3] = rTmpMat[0][3];
02145
02146     _matrix[1][0] = rTmpMat[1][0];
02147     _matrix[1][1] = rTmpMat[1][1];
02148     _matrix[1][2] = rTmpMat[1][2];
02149     _matrix[1][3] = rTmpMat[1][3];
02150
02151     _matrix[2][0] = rTmpMat[2][0];
02152     _matrix[2][1] = rTmpMat[2][1];
02153     _matrix[2][2] = rTmpMat[2][2];
02154     _matrix[2][3] = rTmpMat[2][3];
02155
02156     _matrix[3][0] = rTmpMat[3][0];
02157     _matrix[3][1] = rTmpMat[3][1];
02158     _matrix[3][2] = rTmpMat[3][2];
02159     _matrix[3][3] = rTmpMat[3][3];
02160 }

template<class ValueTypeT >
template<class ValueTypeR >
void OSG::TransformationMatrix< ValueTypeT >::multLeft ( const TransformationMatrix< ValueTypeR > &  mat  )  [inline]

Definition at line 2164 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::TransformationMatrix< ValueTypeT >::rowMulCol4().

02166 {
02167     ValueTypeT rTmpMat[4][4];
02168
02169     (rTmpMat)[0][0] = rowMulCol4((matrix), 0, (*this), 0);
02170     (rTmpMat)[0][1] = rowMulCol4((matrix), 1, (*this), 0);
02171     (rTmpMat)[0][2] = rowMulCol4((matrix), 2, (*this), 0);
02172     (rTmpMat)[0][3] = rowMulCol4((matrix), 3, (*this), 0);
02173
02174     (rTmpMat)[1][0] = rowMulCol4((matrix), 0, (*this), 1);
02175     (rTmpMat)[1][1] = rowMulCol4((matrix), 1, (*this), 1);
02176     (rTmpMat)[1][2] = rowMulCol4((matrix), 2, (*this), 1);
02177     (rTmpMat)[1][3] = rowMulCol4((matrix), 3, (*this), 1);
02178
02179     (rTmpMat)[2][0] = rowMulCol4((matrix), 0, (*this), 2);
02180     (rTmpMat)[2][1] = rowMulCol4((matrix), 1, (*this), 2);
02181     (rTmpMat)[2][2] = rowMulCol4((matrix), 2, (*this), 2);
02182     (rTmpMat)[2][3] = rowMulCol4((matrix), 3, (*this), 2);
02183
02184     (rTmpMat)[3][0] = rowMulCol4((matrix), 0, (*this), 3);
02185     (rTmpMat)[3][1] = rowMulCol4((matrix), 1, (*this), 3);
02186     (rTmpMat)[3][2] = rowMulCol4((matrix), 2, (*this), 3);
02187     (rTmpMat)[3][3] = rowMulCol4((matrix), 3, (*this), 3);
02188
02189     _matrix[0][0] = rTmpMat[0][0];
02190     _matrix[0][1] = rTmpMat[0][1];
02191     _matrix[0][2] = rTmpMat[0][2];
02192     _matrix[0][3] = rTmpMat[0][3];
02193
02194     _matrix[1][0] = rTmpMat[1][0];
02195     _matrix[1][1] = rTmpMat[1][1];
02196     _matrix[1][2] = rTmpMat[1][2];
02197     _matrix[1][3] = rTmpMat[1][3];
02198
02199     _matrix[2][0] = rTmpMat[2][0];
02200     _matrix[2][1] = rTmpMat[2][1];
02201     _matrix[2][2] = rTmpMat[2][2];
02202     _matrix[2][3] = rTmpMat[2][3];
02203
02204     _matrix[3][0] = rTmpMat[3][0];
02205     _matrix[3][1] = rTmpMat[3][1];
02206     _matrix[3][2] = rTmpMat[3][2];
02207     _matrix[3][3] = rTmpMat[3][3];
02208 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::add ( const TransformationMatrix< ValueTypeT > &  matrix  )  [inline]

Definition at line 2213 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

02214 {
02215     _matrix[0][0] += matrix._matrix[0][0];
02216     _matrix[0][1] += matrix._matrix[0][1];
02217     _matrix[0][2] += matrix._matrix[0][2];
02218     _matrix[0][3] += matrix._matrix[0][3];
02219
02220     _matrix[1][0] += matrix._matrix[1][0];
02221     _matrix[1][1] += matrix._matrix[1][1];
02222     _matrix[1][2] += matrix._matrix[1][2];
02223     _matrix[1][3] += matrix._matrix[1][3];
02224
02225     _matrix[2][0] += matrix._matrix[2][0];
02226     _matrix[2][1] += matrix._matrix[2][1];
02227     _matrix[2][2] += matrix._matrix[2][2];
02228     _matrix[2][3] += matrix._matrix[2][3];
02229
02230     _matrix[3][0] += matrix._matrix[3][0];
02231     _matrix[3][1] += matrix._matrix[3][1];
02232     _matrix[3][2] += matrix._matrix[3][2];
02233     _matrix[3][3] += matrix._matrix[3][3];
02234 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::scale ( ValueTypeT  s  )  [inline]

Definition at line 2239 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::TransformationMatrix< ValueTypeT >::exp(), OSG::TransformationMatrix< ValueTypeT >::expOf(), OSG::TransformationMatrix< ValueTypeT >::log(), OSG::TransformationMatrix< ValueTypeT >::logOf(), OSG::TransformationMatrix< ValueTypeT >::polarDecompose(), OSG::TransformationMatrix< ValueTypeT >::sqrt(), and OSG::TransformationMatrix< ValueTypeT >::sqrtOf().

02240 {
02241     _matrix[0][0] *= s;
02242     _matrix[0][1] *= s;
02243     _matrix[0][2] *= s;
02244     _matrix[0][3] *= s;
02245
02246     _matrix[1][0] *= s;
02247     _matrix[1][1] *= s;
02248     _matrix[1][2] *= s;
02249     _matrix[1][3] *= s;
02250
02251     _matrix[2][0] *= s;
02252     _matrix[2][1] *= s;
02253     _matrix[2][2] *= s;
02254     _matrix[2][3] *= s;
02255
02256     _matrix[3][0] *= s;
02257     _matrix[3][1] *= s;
02258     _matrix[3][2] *= s;
02259     _matrix[3][3] *= s;
02260 }

template<class ValueTypeT>
void OSG::TransformationMatrix< ValueTypeT >::addScaled ( const TransformationMatrix< ValueTypeT > &  matrix,
ValueTypeT  s 
) [inline]

Definition at line 2265 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::TransformationMatrix< ValueTypeT >::exp(), OSG::TransformationMatrix< ValueTypeT >::expOf(), OSG::TransformationMatrix< ValueTypeT >::log(), OSG::TransformationMatrix< ValueTypeT >::logOf(), OSG::TransformationMatrix< ValueTypeT >::polarDecompose(), OSG::TransformationMatrix< ValueTypeT >::sqrt(), and OSG::TransformationMatrix< ValueTypeT >::sqrtOf().

02268 {
02269     _matrix[0][0] += s*matrix._matrix[0][0];
02270     _matrix[0][1] += s*matrix._matrix[0][1];
02271     _matrix[0][2] += s*matrix._matrix[0][2];
02272     _matrix[0][3] += s*matrix._matrix[0][3];
02273
02274     _matrix[1][0] += s*matrix._matrix[1][0];
02275     _matrix[1][1] += s*matrix._matrix[1][1];
02276     _matrix[1][2] += s*matrix._matrix[1][2];
02277     _matrix[1][3] += s*matrix._matrix[1][3];
02278
02279     _matrix[2][0] += s*matrix._matrix[2][0];
02280     _matrix[2][1] += s*matrix._matrix[2][1];
02281     _matrix[2][2] += s*matrix._matrix[2][2];
02282     _matrix[2][3] += s*matrix._matrix[2][3];
02283
02284     _matrix[3][0] += s*matrix._matrix[3][0];
02285     _matrix[3][1] += s*matrix._matrix[3][1];
02286     _matrix[3][2] += s*matrix._matrix[3][2];
02287     _matrix[3][3] += s*matrix._matrix[3][3];
02288 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::negate ( void   )  [inline]

Definition at line 2293 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::TransformationMatrix< ValueTypeT >::decompose(), and OSG::TransformationMatrix< ValueTypeT >::log().

02294 {
02295     _matrix[0][0] *= -1.0;
02296     _matrix[0][1] *= -1.0;
02297     _matrix[0][2] *= -1.0;
02298     _matrix[0][3] *= -1.0;
02299
02300     _matrix[1][0] *= -1.0;
02301     _matrix[1][1] *= -1.0;
02302     _matrix[1][2] *= -1.0;
02303     _matrix[1][3] *= -1.0;
02304
02305     _matrix[2][0] *= -1.0;
02306     _matrix[2][1] *= -1.0;
02307     _matrix[2][2] *= -1.0;
02308     _matrix[2][3] *= -1.0;
02309
02310     _matrix[3][0] *= -1.0;
02311     _matrix[3][1] *= -1.0;
02312     _matrix[3][2] *= -1.0;
02313     _matrix[3][3] *= -1.0;
02314 }

template<class ValueTypeT >
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::norm1 ( void   )  const [inline]

Returns the sum of absolute values of the entries in this matrix.

Note:
This is NOT the usual 1-norm for matrices.

Definition at line 2322 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::osgAbs().

02323 {
02324     ValueTypeT m = TypeTraits<ValueType>::getZeroElement();
02325
02326     m += osgAbs(_matrix[0][0]);
02327     m += osgAbs(_matrix[0][1]);
02328     m += osgAbs(_matrix[0][2]);
02329     m += osgAbs(_matrix[0][3]);
02330     m += osgAbs(_matrix[1][0]);
02331     m += osgAbs(_matrix[1][1]);
02332     m += osgAbs(_matrix[1][2]);
02333     m += osgAbs(_matrix[1][3]);
02334     m += osgAbs(_matrix[2][0]);
02335     m += osgAbs(_matrix[2][1]);
02336     m += osgAbs(_matrix[2][2]);
02337     m += osgAbs(_matrix[2][3]);
02338     m += osgAbs(_matrix[3][0]);
02339     m += osgAbs(_matrix[3][1]);
02340     m += osgAbs(_matrix[3][2]);
02341     m += osgAbs(_matrix[3][3]);
02342
02343     return m;
02344 }

template<class ValueTypeT >
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::norm2 ( void   )  const [inline]

Returns the square root of the sum of squared entries in the matrix.

Note:
This is NOT the usual 2-norm for matrices.

Definition at line 2352 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::osgSqrt().

02353 {
02354     ValueTypeT m = TypeTraits<ValueType>::getZeroElement();
02355     ValueTypeT t;
02356
02357     t = _matrix[0][0]; m += t*t;
02358     t = _matrix[0][1]; m += t*t;
02359     t = _matrix[0][2]; m += t*t;
02360     t = _matrix[0][3]; m += t*t;
02361     t = _matrix[1][0]; m += t*t;
02362     t = _matrix[1][1]; m += t*t;
02363     t = _matrix[1][2]; m += t*t;
02364     t = _matrix[1][3]; m += t*t;
02365     t = _matrix[2][0]; m += t*t;
02366     t = _matrix[2][1]; m += t*t;
02367     t = _matrix[2][2]; m += t*t;
02368     t = _matrix[2][3]; m += t*t;
02369     t = _matrix[3][0]; m += t*t;
02370     t = _matrix[3][1]; m += t*t;
02371     t = _matrix[3][2]; m += t*t;
02372     t = _matrix[3][3]; m += t*t;
02373
02374     return osgSqrt(m);
02375 }

template<class ValueTypeT >
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::normInfinity ( void   )  const [inline]

Returns the largest absolute value of all entries in the matrix.

Note:
This is NOT the usual Infinity-norm for matrices.

Definition at line 2383 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::osgAbs().

Referenced by OSG::TransformationMatrix< ValueTypeT >::exp(), OSG::TransformationMatrix< ValueTypeT >::expOf(), OSG::TransformationMatrix< ValueTypeT >::log(), and OSG::TransformationMatrix< ValueTypeT >::logOf().

02384 {
02385     ValueTypeT m = TypeTraits<ValueType>::getZeroElement();
02386     ValueTypeT t;
02387
02388     if((t = osgAbs(_matrix[0][0])) > m)
02389         m = t;
02390     if((t = osgAbs(_matrix[0][1])) > m)
02391         m = t;
02392     if((t = osgAbs(_matrix[0][2])) > m)
02393         m = t;
02394     if((t = osgAbs(_matrix[0][3])) > m)
02395         m = t;
02396     if((t = osgAbs(_matrix[1][0])) > m)
02397         m = t;
02398     if((t = osgAbs(_matrix[1][1])) > m)
02399         m = t;
02400     if((t = osgAbs(_matrix[1][2])) > m)
02401         m = t;
02402     if((t = osgAbs(_matrix[1][3])) > m)
02403         m = t;
02404     if((t = osgAbs(_matrix[2][0])) > m)
02405         m = t;
02406     if((t = osgAbs(_matrix[2][1])) > m)
02407         m = t;
02408     if((t = osgAbs(_matrix[2][2])) > m)
02409         m = t;
02410     if((t = osgAbs(_matrix[2][3])) > m)
02411         m = t;
02412     if((t = osgAbs(_matrix[3][0])) > m)
02413         m = t;
02414     if((t = osgAbs(_matrix[3][1])) > m)
02415         m = t;
02416     if((t = osgAbs(_matrix[3][2])) > m)
02417         m = t;
02418     if((t = osgAbs(_matrix[3][3])) > m)
02419         m = t;
02420
02421     return m;
02422 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::sqrt ( TransformationMatrix< ValueTypeT > &  result  )  const [inline]

Definition at line 2429 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::det(), OSG::TransformationMatrix< ValueTypeT >::inverse(), OSG::osgAbs(), OSG::osgPow(), OSG::TransformationMatrix< ValueTypeT >::scale(), OSG::TransformationMatrix< ValueTypeT >::setIdentity(), and OSG::TransformationMatrix< ValueTypeT >::setValue().

Referenced by OSG::TransformationMatrix< ValueTypeT >::log().

02430 {
02431     TransformationMatrix iX;
02432     TransformationMatrix  Y;
02433     TransformationMatrix iY;
02434
02435     ValueTypeT  g;
02436     ValueTypeT ig;
02437
02438     result.setValue(*this);
02439
02440     Y.setIdentity();
02441
02442     for(UInt32 i = 0; i < 6; i++)
02443     {
02444         result.inverse(iX);
02445
02446         Y.inverse(iY);
02447
02448         g = osgAbs(osgPow(result.det() * Y.det(), ValueTypeT(-0.125)));
02449
02450         ig = ValueTypeT(1.0 / g);
02451
02452         result.scale    (g     );
02453         result.addScaled(iY, ig);
02454         result.scale    (0.5   );
02455
02456         Y.scale    (g     );
02457         Y.addScaled(iX, ig);
02458         Y.scale    (0.5   );
02459     }
02460
02461     // ToDo: return should depend on achieved accuracy
02462     return true;
02463 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::sqrtOf ( const TransformationMatrix< ValueTypeT > &  matrix  )  [inline]

Definition at line 2470 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::det(), OSG::TransformationMatrix< ValueTypeT >::inverse(), OSG::osgAbs(), OSG::osgPow(), OSG::TransformationMatrix< ValueTypeT >::scale(), OSG::TransformationMatrix< ValueTypeT >::setIdentity(), and OSG::TransformationMatrix< ValueTypeT >::setValue().

02472 {
02473     TransformationMatrix iX;
02474     TransformationMatrix  Y;
02475     TransformationMatrix iY;
02476
02477     ValueTypeT  g;
02478     ValueTypeT ig;
02479
02480     setValue(matrix);
02481
02482     Y.setIdentity();
02483
02484     for(Int32 i = 0; i < 6; i++)
02485     {
02486         inverse(iX);
02487
02488         Y.inverse(iY);
02489
02490         g = osgAbs(osgPow(det() * Y.det(), ValueTypeT(-0.125)));
02491
02492         ig = ValueTypeT(1.0 / g);
02493
02494         scale    (g     );
02495         addScaled(iY, ig);
02496         scale    (0.5   );
02497
02498         Y.scale    (g     );
02499         Y.addScaled(iX, ig);
02500         Y.scale    (0.5);
02501     }
02502
02503     // ToDo: return should depend on achieved accuracy
02504     return true;
02505 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::sqrt ( void   )  [inline]

Definition at line 2510 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::det(), OSG::TransformationMatrix< ValueTypeT >::inverse(), OSG::osgAbs(), OSG::osgPow(), OSG::TransformationMatrix< ValueTypeT >::scale(), and OSG::TransformationMatrix< ValueTypeT >::setIdentity().

02511 {
02512     TransformationMatrix iX;
02513     TransformationMatrix  Y;
02514     TransformationMatrix iY;
02515
02516     ValueTypeT  g;
02517     ValueTypeT ig;
02518
02519     Y.setIdentity();
02520
02521     for(Int32 i = 0; i < 6; i++)
02522     {
02523         inverse(iX);
02524
02525         Y.inverse(iY);
02526
02527         g = osgAbs(osgPow(det() * Y.det(), ValueTypeT(-0.125)));
02528
02529         ig = ValueTypeT(1.0 / g);
02530
02531         scale    (g     );
02532         addScaled(iY, ig);
02533         scale    (0.5   );
02534
02535         Y.scale    (g     );
02536         Y.addScaled(iX, ig);
02537         Y.scale    (0.5   );
02538     }
02539
02540     // ToDo: return should depend on achieved accuracy
02541     return true;
02542 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::log ( TransformationMatrix< ValueTypeT > &  result  )  const [inline]

Definition at line 2549 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::TransformationMatrix< ValueTypeT >::negate(), OSG::TransformationMatrix< ValueTypeT >::normInfinity(), OSG::TransformationMatrix< ValueTypeT >::scale(), OSG::TransformationMatrix< ValueTypeT >::setValue(), and OSG::TransformationMatrix< ValueTypeT >::sqrt().

02550 {
02551     const Int32      maxiter = 12;
02552           Int32      k       = 0;
02553           Int32      i       = 0;
02554     const ValueTypeT eps     = 1e-12;
02555
02556     TransformationMatrix A(*this);
02557     TransformationMatrix Z;
02558
02559     // Take repeated square roots to reduce spectral radius
02560     Z.setValue(A);
02561
02562     Z[0][0] -= TypeTraits<ValueType>::getOneElement();
02563     Z[1][1] -= TypeTraits<ValueType>::getOneElement();
02564     Z[2][2] -= TypeTraits<ValueType>::getOneElement();
02565     Z[3][3] -= TypeTraits<ValueType>::getOneElement();
02566
02567     while(Z.normInfinity() > 0.5)
02568     {
02569         A.sqrt    ( );
02570         Z.setValue(A);
02571
02572         Z[0][0] -= TypeTraits<ValueType>::getOneElement();
02573         Z[1][1] -= TypeTraits<ValueType>::getOneElement();
02574         Z[2][2] -= TypeTraits<ValueType>::getOneElement();
02575         Z[3][3] -= TypeTraits<ValueType>::getOneElement();
02576
02577         k++;
02578     }
02579
02580     A[0][0] -= TypeTraits<ValueType>::getOneElement();
02581     A[1][1] -= TypeTraits<ValueType>::getOneElement();
02582     A[2][2] -= TypeTraits<ValueType>::getOneElement();
02583     A[3][3] -= TypeTraits<ValueType>::getOneElement();
02584
02585     A.negate();
02586
02587     result.setValue(A);
02588
02589     Z.setValue(A);
02590
02591     i = 1;
02592
02593     while(Z.normInfinity() > eps && i < maxiter)
02594     {
02595         Z.mult(A);
02596
02597         i++;
02598
02599         result.addScaled(Z, ValueTypeT(1.0) / ValueTypeT(i));
02600     }
02601
02602     result.scale(ValueTypeT(-1.0) * ValueTypeT(1 << k));
02603
02604     return (i < maxiter);
02605 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::logOf ( const TransformationMatrix< ValueTypeT > &  matrix  )  [inline]

Definition at line 2612 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::TransformationMatrix< ValueTypeT >::normInfinity(), OSG::TransformationMatrix< ValueTypeT >::scale(), and OSG::TransformationMatrix< ValueTypeT >::setValue().

Referenced by OSG::LinearTransform< ValueTypeT >::LinearTransform(), and OSG::LinearTransform< ValueTypeT >::setValue().

02614 {
02615     const Int32      maxiter = 12;
02616           Int32      k       = 0;
02617           Int32      i       = 0;
02618     const ValueTypeT eps     = 1e-12;
02619
02620     TransformationMatrix<ValueTypeT> A(matrix),Z;
02621
02622     // Take repeated square roots to reduce spectral radius
02623     Z.setValue(A);
02624
02625     Z[0][0] -= TypeTraits<ValueType>::getOneElement();
02626     Z[1][1] -= TypeTraits<ValueType>::getOneElement();
02627     Z[2][2] -= TypeTraits<ValueType>::getOneElement();
02628     Z[3][3] -= TypeTraits<ValueType>::getOneElement();
02629
02630     while(Z.normInfinity() > 0.5)
02631     {
02632         A.sqrt();
02633
02634         Z.setValue(A);
02635
02636         Z[0][0] -= TypeTraits<ValueType>::getOneElement();
02637         Z[1][1] -= TypeTraits<ValueType>::getOneElement();
02638         Z[2][2] -= TypeTraits<ValueType>::getOneElement();
02639         Z[3][3] -= TypeTraits<ValueType>::getOneElement();
02640
02641         k++;
02642     }
02643
02644     A[0][0] -= TypeTraits<ValueType>::getOneElement();
02645     A[1][1] -= TypeTraits<ValueType>::getOneElement();
02646     A[2][2] -= TypeTraits<ValueType>::getOneElement();
02647     A[3][3] -= TypeTraits<ValueType>::getOneElement();
02648
02649     A.negate();
02650
02651     setValue(A);
02652
02653     Z.setValue(A);
02654
02655     i = 1;
02656     while(Z.normInfinity() > eps && i < maxiter)
02657     {
02658         Z.mult(A);
02659
02660         i++;
02661
02662         addScaled(Z, ValueTypeT(1.0) / ValueTypeT(i));
02663     }
02664
02665     scale(ValueTypeT(-1.0) * ValueTypeT(1 << k));
02666
02667     return (i<maxiter);
02668 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::exp ( TransformationMatrix< ValueTypeT > &  result  )  const [inline]

Definition at line 2675 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::invertFrom(), OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::TransformationMatrix< ValueTypeT >::multLeft(), N, OSG::TransformationMatrix< ValueTypeT >::normInfinity(), OSG::osgLog(), OSG::TransformationMatrix< ValueTypeT >::scale(), and OSG::TransformationMatrix< ValueTypeT >::setIdentity().

02676 {
02677     const Int32                q = 6;
02678
02679           TransformationMatrix A(*this);
02680           TransformationMatrix D;
02681           TransformationMatrix N;
02682
02683           Int32                j = 1;
02684           Int32                k;
02685
02686           ValueTypeT           c(1.0);
02687
02688     j += Int32(osgLog(A.normInfinity() / 0.693));
02689
02690     if(j < 0)
02691         j = 0;
02692
02693     A.scale(ValueTypeT(1.0f / (1 << j)));
02694
02695     result.setIdentity();
02696
02697     for(k = 1; k <= q; k++)
02698     {
02699         c *= ValueTypeT(q - k + 1) / ValueTypeT(k * (2 * q - k + 1));
02700
02701         result.multLeft(A);
02702
02703         N.addScaled(result, c);
02704
02705         if(k % 2)
02706         {
02707             D.addScaled(result, -c);
02708         }
02709         else
02710         {
02711             D.addScaled(result,  c);
02712         }
02713     }
02714
02715     result.invertFrom(D);
02716     result.mult      (N);
02717
02718     for(k = 0; k < j; k++)
02719         result.mult(result);
02720
02721     // ToDo: return value
02722     return true;
02723 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::expOf ( const TransformationMatrix< ValueTypeT > &  matrix  )  [inline]

Definition at line 2729 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::invertFrom(), OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::TransformationMatrix< ValueTypeT >::multLeft(), N, OSG::TransformationMatrix< ValueTypeT >::normInfinity(), OSG::osgLog(), OSG::TransformationMatrix< ValueTypeT >::scale(), and OSG::TransformationMatrix< ValueTypeT >::setIdentity().

Referenced by OSG::LinearTransform< ValueTypeT >::getTransform(), and OSG::LinearTransform< ValueTypeT >::operator MatrixType().

02731 {
02732     const Int32                q = 6;
02733
02734           TransformationMatrix A(matrix);
02735           TransformationMatrix D;
02736           TransformationMatrix N;
02737
02738           Int32                j = 1;
02739           Int32                k;
02740
02741           ValueTypeT           c(1.0);
02742
02743     j += int(osgLog(A.normInfinity() / 0.693));
02744
02745     if(j < 0)
02746         j = 0;
02747
02748     A.scale(1.0 / (ValueTypeT(1 << j)));
02749
02750     setIdentity();
02751
02752     for(k = 1; k <= q; k++)
02753     {
02754         c *= ValueTypeT(q - k + 1) / ValueTypeT(k * (2 *q - k + 1));
02755
02756         multLeft(A);
02757
02758         N.addScaled(*this,c);
02759
02760         if(k % 2)
02761         {
02762             D.addScaled(*this, -c);
02763         }
02764         else
02765         {
02766             D.addScaled(*this,  c);
02767         }
02768     }
02769
02770     invertFrom(D);
02771     mult      (N);
02772
02773     for(k = 0; k < j; k++)
02774         mult(*this);
02775
02776     // ToDo: return value
02777     return true;
02778 }

template<class ValueTypeT >
TransformationMatrix< ValueTypeT >::VectorType & OSG::TransformationMatrix< ValueTypeT >::operator[] ( UInt32  uiIndex  )  [inline]

Definition at line 2785 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

02786 {
02787     return _matrix[uiIndex];
02788 }

template<class ValueTypeT >
const TransformationMatrix< ValueTypeT >::VectorType & OSG::TransformationMatrix< ValueTypeT >::operator[] ( UInt32  uiIndex  )  const [inline]

Definition at line 2792 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

02793 {
02794     return _matrix[uiIndex];
02795 }

template<class ValueTypeT >
TransformationMatrix< ValueTypeT > & OSG::TransformationMatrix< ValueTypeT >::operator= ( const TransformationMatrix< ValueTypeT > &  source  )  [inline]

Definition at line 2802 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

02804 {
02805     UInt32 i;
02806
02807     if (this == &source)
02808         return *this;
02809
02810     for(i = 0; i < 4; i++)
02811         _matrix[i] = source._matrix[i];
02812
02813     return *this;
02814 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::operator== ( const TransformationMatrix< ValueTypeT > &  other  )  const [inline]

Definition at line 2824 of file OSGMatrix.inl.

References OSG::Eps, and OSG::TransformationMatrix< ValueTypeT >::equals().

02826 {
02827     return equals(other, Eps);
02828 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::operator!= ( const TransformationMatrix< ValueTypeT > &  other  )  const [inline]

Definition at line 2835 of file OSGMatrix.inl.

02837 {
02838     return ! (*this == other);
02839 }

template<class ValueTypeT >
template<class ValueTypeR , class ValueTypeS >
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::rowMulCol4 ( const TransformationMatrix< ValueTypeR > &  gRowMat,
UInt32  iRow,
const TransformationMatrix< ValueTypeS > &  gColMat,
UInt32  iColumn 
) const [inline, protected]

Definition at line 453 of file OSGMatrix.inl.

Referenced by OSG::TransformationMatrix< ValueTypeT >::mult(), and OSG::TransformationMatrix< ValueTypeT >::multLeft().

00456 {
00457     return
00458         gRowMat[0][iRow] * gColMat[iColumn][0] +
00459         gRowMat[1][iRow] * gColMat[iColumn][1] +
00460         gRowMat[2][iRow] * gColMat[iColumn][2] +
00461         gRowMat[3][iRow] * gColMat[iColumn][3];
00462 }

template<class ValueTypeT>
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::det2_calc ( const ValueTypeT  a1,
const ValueTypeT  a2,
const ValueTypeT  b1,
const ValueTypeT  b2 
) const [inline, protected]

Definition at line 466 of file OSGMatrix.inl.

Referenced by OSG::TransformationMatrix< ValueTypeT >::calcInverse3(), and OSG::TransformationMatrix< ValueTypeT >::det3_calc().

00469 {
00470     return (a1 * b2) - (a2 * b1);
00471 }

template<class ValueTypeT>
ValueTypeT OSG::TransformationMatrix< ValueTypeT >::det3_calc ( const ValueTypeT  a1,
const ValueTypeT  a2,
const ValueTypeT  a3,
const ValueTypeT  b1,
const ValueTypeT  b2,
const ValueTypeT  b3,
const ValueTypeT  c1,
const ValueTypeT  c2,
const ValueTypeT  c3 
) const [inline, protected]

Definition at line 474 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::det2_calc().

Referenced by OSG::TransformationMatrix< ValueTypeT >::calcInverse(), and OSG::TransformationMatrix< ValueTypeT >::det().

00484 {
00485     return
00486         a1 * det2_calc(b2, b3, c2, c3) -
00487         a2 * det2_calc(b1, b3, c1, c3) +
00488         a3 * det2_calc(b1, b2, c1, c2);
00489 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::calcInverse ( TransformationMatrix< ValueTypeT > *  destM,
const TransformationMatrix< ValueTypeT > *  srcM 
) const [inline, protected]

Compute the inverse of srcM and store it in destM.

Note:
The two matrices may NOT be aliased.

Definition at line 2846 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, OSG::TransformationMatrix< ValueTypeT >::det3_calc(), FWARNING, OSG::osgAbs(), and OSG::TransformationMatrix< ValueTypeT >::setIdentity().

Referenced by OSG::TransformationMatrix< ValueTypeT >::inverse(), OSG::TransformationMatrix< ValueTypeT >::invert(), and OSG::TransformationMatrix< ValueTypeT >::invertFrom().

02848 {
02849           VectorType *dM = destM->_matrix;
02850     const VectorType *sM = srcM ->_matrix;
02851
02852     ValueTypeT det3A0 = det3_calc(sM[1][1], sM[1][2], sM[1][3],
02853                                   sM[2][1], sM[2][2], sM[2][3],
02854                                   sM[3][1], sM[3][2], sM[3][3] );
02855     ValueTypeT det3A1 = det3_calc(sM[1][0], sM[1][2], sM[1][3],
02856                                   sM[2][0], sM[2][2], sM[2][3],
02857                                   sM[3][0], sM[3][2], sM[3][3] );
02858     ValueTypeT det3A2 = det3_calc(sM[1][0], sM[1][1], sM[1][3],
02859                                   sM[2][0], sM[2][1], sM[2][3],
02860                                   sM[3][0], sM[3][1], sM[3][3] );
02861     ValueTypeT det3A3 = det3_calc(sM[1][0], sM[1][1], sM[1][2],
02862                                   sM[2][0], sM[2][1], sM[2][2],
02863                                   sM[3][0], sM[3][1], sM[3][2] );
02864
02865     ValueTypeT det4   = sM[0][0] * det3A0 - sM[0][1] * det3A1 +
02866                         sM[0][2] * det3A2 - sM[0][3] * det3A3;
02867
02868     if(osgAbs(det4) < TypeTraits<ValueTypeT>::ZeroEps())
02869     {
02870         FWARNING(("TransformationMatrix<>::calcInverse: "
02871                   "Singular matrix, no inverse!\n"));
02872
02873         destM->setIdentity();
02874
02875         return false;
02876     }
02877
02878     ValueTypeT det4Inv = TypeTraits<ValueTypeT>::getOneElement() / det4;
02879
02880     dM[0][0] =   det3A0                                   * det4Inv;
02881     dM[0][1] = - det3_calc(sM[0][1], sM[0][2], sM[0][3],
02882                            sM[2][1], sM[2][2], sM[2][3],
02883                            sM[3][1], sM[3][2], sM[3][3] ) * det4Inv;
02884     dM[0][2] =   det3_calc(sM[0][1], sM[0][2], sM[0][3],
02885                            sM[1][1], sM[1][2], sM[1][3],
02886                            sM[3][1], sM[3][2], sM[3][3] ) * det4Inv;
02887     dM[0][3] = - det3_calc(sM[0][1], sM[0][2], sM[0][3],
02888                            sM[1][1], sM[1][2], sM[1][3],
02889                            sM[2][1], sM[2][2], sM[2][3] ) * det4Inv;
02890
02891     dM[1][0] = - det3A1                                   * det4Inv;
02892     dM[1][1] =   det3_calc(sM[0][0], sM[0][2], sM[0][3],
02893                            sM[2][0], sM[2][2], sM[2][3],
02894                            sM[3][0], sM[3][2], sM[3][3] ) * det4Inv;
02895     dM[1][2] = - det3_calc(sM[0][0], sM[0][2], sM[0][3],
02896                            sM[1][0], sM[1][2], sM[1][3],
02897                            sM[3][0], sM[3][2], sM[3][3] ) * det4Inv;
02898     dM[1][3] =   det3_calc(sM[0][0], sM[0][2], sM[0][3],
02899                            sM[1][0], sM[1][2], sM[1][3],
02900                            sM[2][0], sM[2][2], sM[2][3] ) * det4Inv;
02901
02902     dM[2][0] =   det3A2                                   * det4Inv;
02903     dM[2][1] = - det3_calc(sM[0][0], sM[0][1], sM[0][3],
02904                            sM[2][0], sM[2][1], sM[2][3],
02905                            sM[3][0], sM[3][1], sM[3][3] ) * det4Inv;
02906     dM[2][2] =   det3_calc(sM[0][0], sM[0][1], sM[0][3],
02907                            sM[1][0], sM[1][1], sM[1][3],
02908                            sM[3][0], sM[3][1], sM[3][3] ) * det4Inv;
02909     dM[2][3] = - det3_calc(sM[0][0], sM[0][1], sM[0][3],
02910                            sM[1][0], sM[1][1], sM[1][3],
02911                            sM[2][0], sM[2][1], sM[2][3] ) * det4Inv;
02912
02913
02914     dM[3][0] = - det3A3                                   * det4Inv;
02915     dM[3][1] =   det3_calc(sM[0][0], sM[0][1], sM[0][2],
02916                            sM[2][0], sM[2][1], sM[2][2],
02917                            sM[3][0], sM[3][1], sM[3][2] ) * det4Inv;
02918     dM[3][2] = - det3_calc(sM[0][0], sM[0][1], sM[0][2],
02919                            sM[1][0], sM[1][1], sM[1][2],
02920                            sM[3][0], sM[3][1], sM[3][2] ) * det4Inv;
02921     dM[3][3] =   det3_calc(sM[0][0], sM[0][1], sM[0][2],
02922                            sM[1][0], sM[1][1], sM[1][2],
02923                            sM[2][0], sM[2][1], sM[2][2] ) * det4Inv;
02924
02925     return true;
02926 }

template<class ValueTypeT >
bool OSG::TransformationMatrix< ValueTypeT >::calcInverse3 ( TransformationMatrix< ValueTypeT > *  destM,
const TransformationMatrix< ValueTypeT > *  srcM 
) const [inline, protected]

Compute the inverse of the upper 3x3 part of srcM and store it in destM, overwriting all elements of destM.

Note:
The two matrices may NOT be aliased.

Definition at line 2934 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, OSG::TransformationMatrix< ValueTypeT >::det2_calc(), OSG::TransformationMatrix< ValueTypeT >::det3(), FWARNING, OSG::osgAbs(), and OSG::TransformationMatrix< ValueTypeT >::setIdentity().

Referenced by OSG::TransformationMatrix< ValueTypeT >::inverse3(), OSG::TransformationMatrix< ValueTypeT >::invert3(), and OSG::TransformationMatrix< ValueTypeT >::invertFrom3().

02936 {
02937           VectorType *dM = destM->_matrix;
02938     const VectorType *sM = srcM ->_matrix;
02939
02940     ValueTypeT det2A0 = det2_calc(sM[1][1], sM[1][2], sM[2][1], sM[2][2]);
02941     ValueTypeT det2A1 = det2_calc(sM[1][0], sM[1][2], sM[2][0], sM[2][2]);
02942     ValueTypeT det2A2 = det2_calc(sM[1][0], sM[1][1], sM[2][0], sM[2][1]);
02943
02944     ValueTypeT det3   = sM[0][0] * det2A0 -
02945                         sM[0][1] * det2A1 +
02946                         sM[0][2] * det2A2;
02947
02948
02949     if(osgAbs(det3) < TypeTraits<ValueTypeT>::ZeroEps())
02950     {
02951         FWARNING(("TransformationMatrix<>::calcInverse3: "
02952                   "Singular matrix, no inverse!\n"));
02953
02954         destM->setIdentity();
02955
02956         return false;
02957     }
02958
02959     ValueTypeT det3Inv = TypeTraits<ValueTypeT>::getOneElement() / det3;
02960
02961     dM[0][0] =   det2A0 * det3Inv;
02962     dM[0][1] = - det2_calc(sM[0][1], sM[0][2], sM[2][1], sM[2][2]) * det3Inv;
02963     dM[0][2] =   det2_calc(sM[0][1], sM[0][2], sM[1][1], sM[1][2]) * det3Inv;
02964     dM[0][3] =   TypeTraits<ValueTypeT>::getZeroElement();
02965
02966     dM[1][0] = - det2A1 * det3Inv;
02967     dM[1][1] =   det2_calc(sM[0][0], sM[0][2], sM[2][0], sM[2][2]) * det3Inv;
02968     dM[1][2] = - det2_calc(sM[0][0], sM[0][2], sM[1][0], sM[1][2]) * det3Inv;
02969     dM[1][3] =   TypeTraits<ValueTypeT>::getZeroElement();
02970
02971     dM[2][0] =   det2A2 * det3Inv;
02972     dM[2][1] = - det2_calc(sM[0][0], sM[0][1], sM[2][0], sM[2][1]) * det3Inv;
02973     dM[2][2] =   det2_calc(sM[0][0], sM[0][1], sM[1][0], sM[1][1]) * det3Inv;
02974     dM[2][3] =   TypeTraits<ValueTypeT>::getZeroElement();
02975
02976     dM[3][0] =   TypeTraits<ValueTypeT>::getZeroElement();
02977     dM[3][1] =   TypeTraits<ValueTypeT>::getZeroElement();
02978     dM[3][2] =   TypeTraits<ValueTypeT>::getZeroElement();
02979     dM[3][3] =   TypeTraits<ValueTypeT>::getOneElement ();
02980
02981     return true;
02982 }

template<class ValueTypeT >
TransformationMatrix< ValueTypeT >::ValueType OSG::TransformationMatrix< ValueTypeT >::norm1_3x3 ( void   )  const [inline, protected]

Returns the 1-norm of the upper left 3x3 part of this matrix. The 1-norm is also known as maximum absolute column sum norm.

Returns:
1-norm of matrix.

Definition at line 498 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::osgAbs().

Referenced by OSG::TransformationMatrix< ValueTypeT >::polarDecompose().

00499 {
00500     ValueType max;
00501     ValueType t;
00502
00503     max = osgAbs(_matrix[0][0]) +
00504           osgAbs(_matrix[0][1]) +
00505           osgAbs(_matrix[0][2]);
00506
00507     if((t = osgAbs(_matrix[1][0]) +
00508             osgAbs(_matrix[1][1]) +
00509             osgAbs(_matrix[1][2])  ) > max)
00510     {
00511         max = t;
00512     }
00513
00514     if((t = osgAbs(_matrix[2][0]) +
00515             osgAbs(_matrix[2][1]) +
00516             osgAbs(_matrix[2][2])  ) > max)
00517     {
00518         max = t;
00519     }
00520
00521     return max;
00522 }

template<class ValueTypeT >
TransformationMatrix< ValueTypeT >::ValueType OSG::TransformationMatrix< ValueTypeT >::normInf_3x3 ( void   )  const [inline, protected]

Returns the infinity-norm of the upper left 3x3 part of this matrix. The infinity-norm is also known as maximum absolute row sum norm.

Returns:
infinity-norm of matrix.

Definition at line 531 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, and OSG::osgAbs().

Referenced by OSG::TransformationMatrix< ValueTypeT >::polarDecompose().

00532 {
00533     ValueType max;
00534     ValueType t;
00535
00536     max = osgAbs(_matrix[0][0]) +
00537           osgAbs(_matrix[1][0]) +
00538           osgAbs(_matrix[2][0]);
00539
00540     if((t = osgAbs(_matrix[0][1]) +
00541             osgAbs(_matrix[1][1]) +
00542             osgAbs(_matrix[2][1])  ) > max)
00543     {
00544         max = t;
00545     }
00546
00547     if((t = osgAbs(_matrix[0][2]) +
00548             osgAbs(_matrix[1][2]) +
00549             osgAbs(_matrix[2][2])  ) > max)
00550     {
00551         max = t;
00552     }
00553
00554     return max;
00555 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::adjointT_3x3 ( TransformationMatrix< ValueTypeT > &  result  )  const [inline, protected]

Computes the transpose of the adjoint of the upper left 3x3 part of this matrix and stores it in result. This is used in polarDecomposition.

Parameters:
[out] result Transpose of adjoint.

Definition at line 565 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix.

Referenced by OSG::TransformationMatrix< ValueTypeT >::polarDecompose().

00567 {
00568     result[0][0] = _matrix[1][1] * _matrix[2][2] - _matrix[2][1] * _matrix[1][2];
00569     result[1][0] = _matrix[2][1] * _matrix[0][2] - _matrix[0][1] * _matrix[2][2];
00570     result[2][0] = _matrix[0][1] * _matrix[1][2] - _matrix[1][1] * _matrix[0][2];
00571
00572     result[0][1] = _matrix[1][2] * _matrix[2][0] - _matrix[2][2] * _matrix[1][0];
00573     result[1][1] = _matrix[2][2] * _matrix[0][0] - _matrix[0][2] * _matrix[2][0];
00574     result[2][1] = _matrix[0][2] * _matrix[1][0] - _matrix[1][2] * _matrix[0][0];
00575
00576     result[0][2] = _matrix[1][0] * _matrix[2][1] - _matrix[2][0] * _matrix[1][1];
00577     result[1][2] = _matrix[2][0] * _matrix[0][1] - _matrix[0][0] * _matrix[2][1];
00578     result[2][2] = _matrix[0][0] * _matrix[1][1] - _matrix[1][0] * _matrix[0][1];
00579 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::polarDecompose ( TransformationMatrix< ValueTypeT > &  Q,
TransformationMatrix< ValueTypeT > &  S,
ValueType det 
) const [inline, protected]

Computes the decomposition M = QS of a non-singular, affine matrix M (this) into an orthogonal matrix Q (basically a rotation, but may also reflect) and a symmetric positive semi-definite matrix S (basically a non-uniform scaling in some orthonormal basis). The sign of the determinant of Q can be used to distinguish the case where Q contains a reflection (det(Q) < 0).

Parameters:
[out] Q Rotation and reflection component.
[out] S Scaling component.
[out] det Determinant of Q.

Code taken from Graphics Gems IV article III.4 "Polar Matrix Decomposition".

Definition at line 596 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::adjointT_3x3(), FWARNING, OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::TransformationMatrix< ValueTypeT >::norm1_3x3(), OSG::TransformationMatrix< ValueTypeT >::normInf_3x3(), OSG::osgAbs(), OSG::osgSqrt(), OSG::TransformationMatrix< ValueTypeT >::scale(), OSG::TransformationMatrix< ValueTypeT >::transpose(), and OSG::TransformationMatrix< ValueTypeT >::transposeFrom().

Referenced by OSG::TransformationMatrix< ValueTypeT >::decompose().

00600 {
00601     ValueType const TOL = ValueType(1.0e-6);
00602
00603     TransformationMatrix const &M = *this;
00604     TransformationMatrix        Mk;
00605     TransformationMatrix        Ek;
00606     TransformationMatrix        MkAdjT;
00607
00608     Mk.transposeFrom(M);
00609
00610     ValueType Mk_one = Mk.norm1_3x3  ();
00611     ValueType Mk_inf = Mk.normInf_3x3();
00612
00613     ValueType MkAdjT_one;
00614     ValueType MkAdjT_inf;
00615
00616     ValueType Ek_one;
00617     ValueType Mk_det;
00618
00619     do
00620     {
00621         // compute transpose of adjoint
00622         Mk.adjointT_3x3(MkAdjT);
00623
00624         // Mk_det = det(Mk) -- computed from the adjoint        
00625         Mk_det = Mk[0][0] * MkAdjT[0][0] +
00626                  Mk[1][0] * MkAdjT[1][0] +
00627                  Mk[2][0] * MkAdjT[2][0];
00628
00629         // should this be a close to zero test ?
00630         if(Mk_det == TypeTraits<ValueType>::getZeroElement())
00631         {
00632             FWARNING(("polarDecompose: Mk_det == 0.0\n"));
00633             break;
00634         }
00635
00636         MkAdjT_one = MkAdjT.norm1_3x3  ();
00637         MkAdjT_inf = MkAdjT.normInf_3x3();
00638
00639         // compute update factors
00640         ValueType gamma =
00641             osgSqrt(
00642                 osgSqrt((MkAdjT_one * MkAdjT_inf) / (Mk_one * Mk_inf)) /
00643                 osgAbs(Mk_det));
00644
00645         ValueType g1 = 0.5 * gamma;
00646         ValueType g2 = 0.5 / (gamma * Mk_det);
00647
00648         Ek = Mk;
00649         Mk.scale    (g1          ); // this does:
00650         Mk.addScaled(MkAdjT, g2  ); // Mk = g1 * Mk + g2 * MkAdjT
00651         Ek.addScaled(Mk,     -1.0); // Ek -= Mk;
00652
00653         Ek_one = Ek.norm1_3x3  ();
00654         Mk_one = Mk.norm1_3x3  ();
00655         Mk_inf = Mk.normInf_3x3();
00656
00657     } while(Ek_one > (Mk_one * TOL));
00658
00659     Q = Mk;
00660     Q.transpose();
00661
00662     S = Mk;
00663     S.mult(M);
00664
00665     for(UInt32 i = 0; i < 3; ++i)
00666     {
00667         for(UInt32 j = i; j < 3; ++j)
00668         {
00669             S[j][i] = S[i][j] = 0.5 * (S[j][i] + S[i][j]);
00670         }
00671     }
00672
00673     det = Mk_det;
00674 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::spectralDecompose ( TransformationMatrix< ValueTypeT > &  SO,
VectorType3f k 
) const [inline, protected]

Computes a spectral decomposition of a symmetric positive semi-definite matrix S (this) into a rotation matrix SO and a vector of scaling values k. The decomposition satisfies S = SO K SO^t, where K is the diagonal matrix of scaling factors.

Parameters:
[out] SO Scale orientation rotation matrix.
[out] k Scaling factors.

Code taken from Graphics Gems IV article III.4 "Polar Matrix Decomposition".

Definition at line 689 of file OSGMatrix.inl.

References OSG::osgAbs(), OSG::osgSqrt(), and S.

Referenced by OSG::TransformationMatrix< ValueTypeT >::decompose().

00692 {
00693     UInt32 const next[3]       = {1, 2, 0};
00694     UInt32 const maxIterations = 20;
00695
00696     TransformationMatrix const &S = *this;
00697
00698     ValueType diag[3];
00699     ValueType offDiag[3];
00700
00701     diag[0] = S[0][0];
00702     diag[1] = S[1][1];
00703     diag[2] = S[2][2];
00704
00705     offDiag[0] = S[2][1];
00706     offDiag[1] = S[0][2];
00707     offDiag[2] = S[1][0];
00708
00709     for(UInt32 iter = 0; iter < maxIterations; ++iter)
00710     {
00711         ValueType sm = osgAbs(offDiag[0]) + osgAbs(offDiag[1]) + osgAbs(offDiag[2]);
00712
00713         if(sm == TypeTraits<ValueType>::getZeroElement())
00714         {
00715             break;
00716         }
00717
00718         for(Int32 i = 2; i >= 0; --i)
00719         {
00720             UInt32 p = next[i];
00721             UInt32 q = next[p];
00722
00723             ValueType absOffDiag = osgAbs(offDiag[i]);
00724             ValueType g          = 100.0 * absOffDiag;
00725
00726             if(absOffDiag > 0.0)
00727             {
00728                 ValueType t;
00729                 ValueType h    = diag[q] - diag[p];
00730                 ValueType absh = osgAbs(h);
00731
00732                 if(absh + g == absh)
00733                 {
00734                     t = offDiag[i] / h;
00735                 }
00736                 else
00737                 {
00738                     ValueType theta = 0.5 * h / offDiag[i];
00739                     t = 1.0 / (osgAbs(theta) + osgSqrt(theta * theta + 1.0));
00740
00741                     t = theta < 0.0 ? -t : t;
00742                 }
00743
00744                 ValueType c = 1.0 / osgSqrt(t * t + 1.0);
00745                 ValueType s = t * c;
00746
00747                 ValueType tau = s / (c + 1.0);
00748                 ValueType ta  = t * offDiag[i];
00749
00750                 offDiag[i] = 0.0;
00751
00752                 diag[p] -= ta;
00753                 diag[q] += ta;
00754
00755                 ValueType offDiagq = offDiag[q];
00756
00757                 offDiag[q] -= s * (offDiag[p] + tau * offDiag[q]);
00758                 offDiag[p] += s * (offDiagq   - tau * offDiag[p]);
00759
00760                 for(Int32 j = 2; j >= 0; --j)
00761                 {
00762                     ValueType a = SO[p][j];
00763                     ValueType b = SO[q][j];
00764
00765                     SO[p][j] -= s * (b + tau * a);
00766                     SO[q][j] += s * (a - tau * b);
00767                 }
00768             }
00769         }
00770     }
00771
00772     k[0] = diag[0];
00773     k[1] = diag[1];
00774     k[2] = diag[2];
00775 }

template<class ValueTypeT >
void OSG::TransformationMatrix< ValueTypeT >::decompose ( VectorType3f t,
ValueType f,
QuaternionType r,
QuaternionType so,
VectorType3f s 
) const [inline, protected]

Computes the decomposition of the 4x4 affine matrix M (this) as M = T F R SO S SO^t, where T is a translation matrix, F is +/- I (a reflection), R is a rotation matrix, SO is a rotation matrix and S is a (nonuniform) scale matrix. The results of the decomposition are not returned as matrices but as more appropriate types.

Code taken from Graphics Gems IV article III.4 "Polar Matrix Decomposition". Note: The "spectral axis adjustment" part, i.e. the "snuggle" function, is not implemented here.

Definition at line 790 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::det(), OSG::TransformationMatrix< ValueTypeT >::negate(), OSG::TransformationMatrix< ValueTypeT >::polarDecompose(), S, OSG::QuaternionBase< ValueTypeT >::setValue(), and OSG::TransformationMatrix< ValueTypeT >::spectralDecompose().

Referenced by OSG::TransformationMatrix< ValueTypeT >::getTransform().

00796 {
00797     TransformationMatrix A = *this;
00798     TransformationMatrix Q;
00799     TransformationMatrix S;
00800     TransformationMatrix SO;
00801     ValueType            det;
00802
00803     t[0] = A[3][0];
00804     t[1] = A[3][1];
00805     t[2] = A[3][2];
00806
00807     A[3][0] = 0.0;
00808     A[3][1] = 0.0;
00809     A[3][2] = 0.0;
00810
00811     A[0][3] = 0.0;
00812     A[1][3] = 0.0;
00813     A[2][3] = 0.0;
00814
00815     A.polarDecompose(Q, S, det);
00816
00817     if(det < 0.0)
00818     {
00819         Q.negate();
00820         f = - 1.0;
00821     }
00822     else
00823     {
00824         f = 1.0;
00825     }
00826
00827     r.setValue(Q);
00828
00829     S.spectralDecompose(SO, s);
00830
00831     so.setValue(SO);
00832 }

template<class ValueTypeT>
bool OSG::TransformationMatrix< ValueTypeT >::jacobi ( ValueTypeT  evalues[JacobiRank],
VectorType3f  evectors[JacobiRank],
Int32 &  rots 
) [inline, protected]

Definition at line 839 of file OSGMatrix.inl.

References OSG::TransformationMatrix< ValueTypeT >::_matrix, OSG::osgAbs(), and OSG::osgSqrt().

Referenced by OSG::TransformationMatrix< ValueTypeT >::factor().

00843 {
00844     Real64  sm;
00845     Real64  theta;
00846     Real64  c, s, t;
00847     Real64  tau;
00848     Real64  h, g;
00849     Real64  thresh;
00850     Real64  b[JacobiRank];
00851     Real64  z[JacobiRank];
00852     UInt32  p, q, i, j;
00853     Real64  a[JacobiRank][JacobiRank];
00854
00855     // initializations
00856     for (i = 0; i < JacobiRank; i++)
00857     {
00858         b[i] = evalues[i] = _matrix[i][i];
00859         z[i] = 0.0;
00860
00861         for (j = 0; j < JacobiRank; j++)
00862         {
00863             evectors[i][j] = (i == j) ? 1.0f : 0.0f;
00864             a[i][j] = _matrix[i][j];
00865         }
00866     }
00867
00868     rots = 0;
00869
00870     for(i = 0; i < 50; i++)
00871     {
00872         sm = 0.0;
00873
00874         for(p = 0; p < JacobiRank - 1; p++)
00875         {
00876             for(q = p+1; q < JacobiRank; q++)
00877             {
00878                 sm += osgAbs(a[p][q]);
00879             }
00880         }
00881
00882         if (sm == 0.0)
00883             return false;
00884
00885         thresh = (i < 3 ?
00886                   (.2 * sm / (JacobiRank * JacobiRank)) :
00887                   0.0);
00888
00889         for (p = 0; p < JacobiRank - 1; p++)
00890         {
00891             for (q = p + 1; q < JacobiRank; q++)
00892             {
00893                 g = 100.0 * osgAbs(a[p][q]);
00894
00895                 if (i > 3                                          &&
00896                     (osgAbs(evalues[p]) + g == osgAbs(evalues[p])) &&
00897                     (osgAbs(evalues[q]) + g == osgAbs(evalues[q])))
00898                 {
00899                     a[p][q] = 0.0;
00900                 }
00901                 else if (osgAbs(a[p][q]) > thresh)
00902                 {
00903                     h = evalues[q] - evalues[p];
00904
00905                     if (osgAbs(h) + g == osgAbs(h))
00906                     {
00907                         t = a[p][q] / h;
00908                     }
00909                     else
00910                     {
00911                         theta = .5 * h / a[p][q];
00912                         t = 1.0 / (osgAbs(theta) + osgSqrt(1 + theta * theta));
00913                         if (theta < 0.0)  t = -t;
00914                     }
00915                     // End of computing tangent of rotation angle
00916
00917                     c = 1.0 / osgSqrt(1.0 + t * t);
00918                     s = t * c;
00919
00920                     tau = s / (1.0 + c);
00921                     h   = t * a[p][q];
00922
00923                     z[p]    -= h;
00924                     z[q]    += h;
00925
00926                     evalues[p] -= ValueTypeT(h);
00927                     evalues[q] += ValueTypeT(h);
00928
00929                     a[p][q] = 0.0;
00930
00931                     for (j = 0; j < p; j++)
00932                     {
00933                         g = a[j][p];
00934                         h = a[j][q];
00935
00936                         a[j][p] = g - s * (h + g * tau);
00937                         a[j][q] = h + s * (g - h * tau);
00938                     }
00939
00940                     for (j = p+1; j < q; j++)
00941                     {
00942                         g = a[p][j];
00943                         h = a[j][q];
00944
00945                         a[p][j] = g - s * (h + g * tau);
00946                         a[j][q] = h + s * (g - h * tau);
00947                     }
00948
00949                     for (j = q+1; j < JacobiRank; j++)
00950                     {
00951                         g = a[p][j];
00952                         h = a[q][j];
00953
00954                         a[p][j] = g - s * (h + g * tau);
00955                         a[q][j] = h + s * (g - h * tau);
00956                     }
00957
00958                     for (j = 0; j < JacobiRank; j++)
00959                     {
00960                         g = evectors[j][p];
00961                         h = evectors[j][q];
00962
00963                         evectors[j][p] = ValueTypeT(g - s * (h + g * tau));
00964                         evectors[j][q] = ValueTypeT(h + s * (g - h * tau));
00965                     }
00966                 }
00967                 rots++;
00968             }
00969         }
00970         for (p = 0; p < JacobiRank; p++)
00971         {
00972             evalues[p] = ValueTypeT(b[p] += z[p]);
00973
00974             z[p] = 0;
00975         }
00976     }
00977
00978     return true;
00979 }


Member Data Documentation

template<class ValueTypeT>
VectorType OSG::TransformationMatrix< ValueTypeT >::_matrix[4] [protected]

Definition at line 430 of file OSGMatrix.h.

Referenced by OSG::TransformationMatrix< ValueTypeT >::add(), OSG::TransformationMatrix< ValueTypeT >::addScaled(), OSG::TransformationMatrix< ValueTypeT >::adjointT_3x3(), OSG::TransformationMatrix< ValueTypeT >::calcInverse(), OSG::TransformationMatrix< ValueTypeT >::calcInverse3(), OSG::TransformationMatrix< ValueTypeT >::det(), OSG::TransformationMatrix< ValueTypeT >::det3(), OSG::TransformationMatrix< ValueTypeT >::equals(), OSG::TransformationMatrix< ValueTypeT >::factor(), OSG::TransformationMatrix< ValueTypeT >::getValues(), OSG::TransformationMatrix< ValueTypeT >::jacobi(), OSG::TransformationMatrix< ValueTypeT >::mult(), OSG::TransformationMatrix< ValueTypeT >::mult3x3(), OSG::TransformationMatrix< ValueTypeT >::multFull(), OSG::TransformationMatrix< ValueTypeT >::multLeft(), OSG::TransformationMatrix< ValueTypeT >::multLeftFull(), OSG::TransformationMatrix< ValueTypeT >::negate(), OSG::TransformationMatrix< ValueTypeT >::norm1(), OSG::TransformationMatrix< ValueTypeT >::norm1_3x3(), OSG::TransformationMatrix< ValueTypeT >::norm2(), OSG::TransformationMatrix< ValueTypeT >::normInf_3x3(), OSG::TransformationMatrix< ValueTypeT >::normInfinity(), OSG::TransformationMatrix< ValueTypeT >::operator=(), OSG::TransformationMatrix< ValueTypeT >::operator[](), OSG::TransformationMatrix< ValueTypeT >::scale(), OSG::TransformationMatrix< ValueTypeT >::setIdentity(), OSG::TransformationMatrix< ValueTypeT >::setScale(), OSG::TransformationMatrix< ValueTypeT >::setTransform(), OSG::TransformationMatrix< ValueTypeT >::setTranslate(), OSG::TransformationMatrix< ValueTypeT >::setValue(), OSG::TransformationMatrix< ValueTypeT >::setValueTransposed(), and OSG::TransformationMatrix< ValueTypeT >::TransformationMatrix().

template<class ValueTypeT>
const UInt32 OSG::TransformationMatrix< ValueTypeT >::JacobiRank = 3 [static, protected]

Definition at line 484 of file OSGMatrix.h.

template<class ValueTypeT>
TransformationMatrix< ValueTypeT > OSG::TransformationMatrix< ValueTypeT >::_identityMatrix [inline, static, private]

Definition at line 500 of file OSGMatrix.h.

Referenced by OSG::TransformationMatrix< ValueTypeT >::identity().


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