![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /********************************************************************* 00002 ** Copyright (c) 1999 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 #ifndef matrix4x4_H_ 00006 #define matrix4x4_H_ 00007 00008 //forward declarations 00009 class Dt4dPoint; 00010 class DtPoint; 00011 class DtChord; 00012 class DtVector; 00013 class DtExtent; 00014 00015 #include "geometry/geometryDefines.h" 00016 #include "stdio.h" 00017 00018 typedef unsigned DtMatrix4x4Sub; 00019 00020 // 00021 // 00022 // class DtHomogeneousTransfMatrix 00023 // 00024 // 00025 class DT_DLL_geometry DtHomogeneousTransfMatrix 00026 { 00027 public: 00028 DtHomogeneousTransfMatrix(); 00029 00030 // Initializations. 00031 void initToIdentityTransformation(); 00032 void initTranslation(const DtPoint& wc); 00033 void initScale(double sx, double sy, double sz); 00034 void initShear(double shx, double shy); 00035 void initRotAboutX(double theta); 00036 void initRotAboutY(double theta); 00037 void initRotAboutZ(double theta); 00038 void initPerspective(double distanceToProjectionPlane); 00039 void initPerspectiveToParallel(double zmin); 00040 00041 void setTranslation(const DtPoint& wc); 00042 void setScale(double sx, double sy, double sz); 00043 void setShear(double shx, double shy); 00044 void setRotAboutX(double theta); 00045 void setRotAboutY(double theta); 00046 void setRotAboutZ(double theta); 00047 void setPerspective(double distanceToProjectionPlane); 00048 void setPerspectiveToParallel(double zmin); 00049 00050 void setRow(int col, double sx, double sy, double sz, double sa); 00051 void setColumn(int col, double sx, double sy, double sz, double sa); 00052 00053 // Matrix operations. 00054 void transpose(); 00055 void transposeInto(DtHomogeneousTransfMatrix& out) const; 00056 void invert(); 00057 void invertInto(DtHomogeneousTransfMatrix& out) const; 00058 void concatenate(const DtHomogeneousTransfMatrix& m1, 00059 const DtHomogeneousTransfMatrix& m2); 00060 // Safe to use on itself 00061 00062 // Transformation operations. 00063 void transformPoint(DtPoint& out, const DtPoint& in) const; 00064 void transformPoint(DtPoint& inout) const; 00065 void transformVector(DtVector& out, const DtVector& in) const; 00066 void transformVector(DtVector& inout) const; 00067 void transformChord(DtChord& out, const DtChord& in) const; 00068 void transformChord(DtChord& inout) const; 00069 void transformExtent(DtExtent& inout) const; 00070 00071 // returns true if the matrix is identity 00072 bool isIdentity() const; 00073 00074 // I/O. 00075 bool readFrom(FILE* fp); 00076 bool writeTo(FILE* fp); 00077 void dump(const char* label, int indentLevel) const; 00078 00079 protected: 00080 00081 // Homogeneous coordinates are needed for above transformations. 00082 void transform(Dt4dPoint& out, const Dt4dPoint& in) const; 00083 void swapRow(int row1, int row2); 00084 void divideRow(int row, double divisor); 00085 00086 protected: 00087 00088 double myMatrix[4][4]; 00089 }; 00090 00091 #endif