00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SBMATRIX_H
00021 #define COIN_SBMATRIX_H
00022
00023 #include <stdio.h>
00024 #include <Inventor/SbBasic.h>
00025
00026 class SbLine;
00027 class SbRotation;
00028 class SbVec3f;
00029 class SbVec4f;
00030
00031 typedef float SbMat[4][4];
00032
00033 class COIN_DLL_API SbMatrix {
00034 public:
00035 SbMatrix(void);
00036 SbMatrix(const float a11, const float a12, const float a13, const float a14,
00037 const float a21, const float a22, const float a23, const float a24,
00038 const float a31, const float a32, const float a33, const float a34,
00039 const float a41, const float a42, const float a43, const float a44);
00040 SbMatrix(const SbMat & matrix);
00041 SbMatrix(const SbMat * matrix);
00042 ~SbMatrix(void);
00043
00044 SbMatrix & operator =(const SbMat & m);
00045
00046 operator float*(void);
00047 SbMatrix & operator =(const SbMatrix & m);
00048 void setValue(const SbMat & m);
00049 const SbMat & getValue(void) const;
00050
00051 void makeIdentity(void);
00052 void setRotate(const SbRotation & q);
00053 SbMatrix inverse(void) const;
00054 float det3(int r1, int r2, int r3,
00055 int c1, int c2, int c3) const;
00056 float det3(void) const;
00057 float det4(void) const;
00058
00059 SbBool equals(const SbMatrix & m, float tolerance) const;
00060
00061
00062 operator SbMat&(void);
00063 float * operator [](int i);
00064 const float * operator [](int i) const;
00065 SbMatrix & operator =(const SbRotation & q);
00066 SbMatrix & operator *=(const SbMatrix & m);
00067 friend COIN_DLL_API SbMatrix operator *(const SbMatrix & m1, const SbMatrix & m2);
00068 friend COIN_DLL_API int operator ==(const SbMatrix & m1, const SbMatrix & m2);
00069 friend COIN_DLL_API int operator !=(const SbMatrix & m1, const SbMatrix & m2);
00070 void getValue(SbMat & m) const;
00071 static SbMatrix identity(void);
00072 void setScale(const float s);
00073 void setScale(const SbVec3f & s);
00074 void setTranslate(const SbVec3f & t);
00075 void setTransform(const SbVec3f & t, const SbRotation & r, const SbVec3f & s);
00076 void setTransform(const SbVec3f & t, const SbRotation & r, const SbVec3f & s,
00077 const SbRotation & so);
00078 void setTransform(const SbVec3f & translation,
00079 const SbRotation & rotation, const SbVec3f & scaleFactor,
00080 const SbRotation & scaleOrientation, const SbVec3f & center);
00081 void getTransform(SbVec3f & t, SbRotation & r,
00082 SbVec3f & s, SbRotation & so) const;
00083 void getTransform(SbVec3f & translation, SbRotation & rotation,
00084 SbVec3f & scaleFactor, SbRotation & scaleOrientation,
00085 const SbVec3f & center) const;
00086 SbBool factor(SbMatrix & r, SbVec3f & s, SbMatrix & u, SbVec3f & t,
00087 SbMatrix & proj);
00088 SbBool LUDecomposition(int index[4], float & d);
00089 void LUBackSubstitution(int index[4], float b[4]) const;
00090 SbMatrix transpose(void) const;
00091 SbMatrix & multRight(const SbMatrix & m);
00092 SbMatrix & multLeft(const SbMatrix & m);
00093 void multMatrixVec(const SbVec3f & src, SbVec3f & dst) const;
00094 void multVecMatrix(const SbVec3f & src, SbVec3f & dst) const;
00095 void multDirMatrix(const SbVec3f & src, SbVec3f & dst) const;
00096 void multLineMatrix(const SbLine & src, SbLine & dst) const;
00097 void multVecMatrix(const SbVec4f & src, SbVec4f & dst) const;
00098
00099 void print(FILE * fp) const;
00100
00101 private:
00102 float matrix[4][4];
00103
00104 void operator /=(const float v);
00105 void operator *=(const float v);
00106 };
00107
00108 COIN_DLL_API SbMatrix operator *(const SbMatrix & m1, const SbMatrix & m2);
00109 COIN_DLL_API int operator ==(const SbMatrix & m1, const SbMatrix & m2);
00110 COIN_DLL_API int operator !=(const SbMatrix & m1, const SbMatrix & m2);
00111
00112 #endif // !COIN_SBMATRIX_H