Ignore:
Timestamp:
06/10/08 13:15:59 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.h

    r2746 r2751  
    55 
    66 
    7 //namespace GtpVisibilityPreprocessor { 
     7namespace CHCDemo  
     8{ 
     9 
    810 
    911class Vector3; 
     
    1416{ 
    1517public: 
    16         float x[4][4]; // first index is column [x], the second is row [y] 
    17  
    18         Matrix4x4() { } 
    19  
    20         // here xXY - 'X' is row, and 'Y' is column - classical mathematical notation 
     18        /** Default constructor initialising nothig. 
     19        */ 
     20        Matrix4x4(); 
     21        /** here xXY - 'X' is row, and 'Y' is column - classical mathematical notation 
     22        */ 
    2123        Matrix4x4(float x11, float x12, float x13, float x14, 
    22                 float x21, float x22, float x23, float x24, 
    23                 float x31, float x32, float x33, float x34, 
    24                 float x41, float x42, float x43, float x44); 
    25  
     24                      float x21, float x22, float x23, float x24, 
     25                          float x31, float x32, float x33, float x34, 
     26                          float x41, float x42, float x43, float x44); 
     27        /** Constructor setting the columns of the 3x3 part of the matrix. 
     28        */ 
    2629        Matrix4x4(const Vector3 &a, const Vector3 &b, const Vector3 &c); 
    2730 
    2831 
    29         // Assignment operators 
     32        //////////////// 
     33        //-- Assignment operators 
     34 
    3035        Matrix4x4& operator+= (const Matrix4x4 &A);     // add-to 
    3136        Matrix4x4& operator-= (const Matrix4x4 &A);     // subtract-from 
     
    3338        Matrix4x4& operator*= (float A);                // scale by scalar 
    3439 
    35         // Fundamental operations 
    36         /// Invert the matrix .. returns 0 = regular 
     40 
     41        //////////////// 
     42        //-- Fundamental operations 
     43 
     44        /** Invert the matrix .. returns 0 = regular 
     45        */ 
    3746        int Invert();            
    38         /// Transpose the matrix 
     47        /** Transpose the matrix 
     48        */ 
    3949        void Transpose();        
     50        /** Sets the columns of the 3x3 part of the matrix. 
     51        */ 
     52        void SetColumns(const Vector3 &a, const Vector3 &b, const Vector3 &c); 
    4053 
    41         void 
    42                 SetColumns(const Vector3 &a, const Vector3 &b, const Vector3 &c); 
    43  
    44         float Det3x3() const { 
    45                 return (x[0][0]*x[1][1]*x[2][2] + \ 
    46                         x[1][0]*x[2][1]*x[0][2] + \ 
    47                         x[2][0]*x[0][1]*x[1][2] - \ 
    48                         x[2][0]*x[1][1]*x[0][2] - \ 
    49                         x[0][0]*x[2][1]*x[1][2] - \ 
    50                         x[1][0]*x[0][1]*x[2][2]); 
    51         } 
     54        float Det3x3() const; 
    5255 
    5356 
    54         friend Matrix4x4 Invert(const Matrix4x4 &M);    // Invert a given matrix 
    55         friend Matrix4x4 Transpose(const Matrix4x4 &M); // Transpose a given matrix 
     57        //////////// 
     58        //-- members 
    5659 
    57         // Create various types of matrix. 
     60        float x[4][4]; // first index is column [x], the second is row [y] 
     61 
     62 
     63        //////////////////// 
     64 
     65        // Invert a given matrix 
     66        friend Matrix4x4 Invert(const Matrix4x4 &M); 
     67        // Transpose a given matrix 
     68        friend Matrix4x4 Transpose(const Matrix4x4 &M);  
     69 
     70 
     71        /////////// 
     72        //-- Create various types of matrix. 
     73 
    5874        friend Matrix4x4 IdentityMatrix(); 
    5975        friend Matrix4x4 ZeroMatrix(); 
     
    94110        friend Vector3 GetTranslation(const Matrix4x4 &M); 
    95111 
    96         // Construct rotation description according VRML'97 specification 
    97         //  const CVector4D SFRotation(void) const; 
    98  
    99  
    100  
    101112        // Overloaded output operator. 
    102113        friend std::ostream& operator<< (std::ostream &s, const Matrix4x4 &M); 
    103114}; 
    104115 
    105 // forward declaration 
     116 
     117///////// 
     118//-- forward declaration 
     119 
     120 
    106121Matrix4x4 IdentityMatrix(); 
    107 Matrix4x4 Invert(const Matrix4x4 &M);   // Invert a given matrix 
    108 Matrix4x4 Transpose(const Matrix4x4 &M);        // Transpose a given matrix 
    109  
    110 // Create various types of matrix. 
     122Matrix4x4 Invert(const Matrix4x4 &M);    
     123Matrix4x4 Transpose(const Matrix4x4 &M);         
    111124Matrix4x4 IdentityMatrix(); 
    112125Matrix4x4 ZeroMatrix(); 
     
    116129Matrix4x4 RotationZMatrix(float Angle); 
    117130Matrix4x4 RotationYPRMatrix(float Yaw, float Pitch, float Roll); 
    118 // about axis 'axis' by angle 'Angle' 
    119131Matrix4x4 RotationAxisMatrix(const Vector3 &axis, float Angle); 
    120 // create the rotation matrix that rotates 'vecFrom' to 'vecTo' 
    121132Matrix4x4 RotationVectorsMatrix(const Vector3 &vecFrom, 
    122133                                                                const Vector3 &vecTo); 
    123  
    124134Matrix4x4 ScaleMatrix(float X, float Y, float Z); 
    125135Matrix4x4 GenRotation(const Vector3 &x, const Vector3 &y, 
     
    127137Matrix4x4 QuadricMatrix(float a, float b, float c, float d, float e, 
    128138                                                float f, float g, float h, float j, float k); 
    129 // returns matrix for transforming normal 
    130139Matrix4x4 NormalTransformMatrix(const Matrix4x4 &M); 
    131  
    132140Matrix4x4 MirrorX(); 
    133141Matrix4x4 MirrorY(); 
    134142Matrix4x4 MirrorZ(); 
    135143Matrix4x4 RotationOnly(const Matrix4x4 &x); 
    136  
    137 // Binary operators 
    138144Matrix4x4 operator+ (const Matrix4x4 &A, const Matrix4x4 &B); 
    139145Matrix4x4 operator- (const Matrix4x4 &A, const Matrix4x4 &B); 
    140146Matrix4x4 operator* (const Matrix4x4 &A, float B); 
    141147Matrix4x4 operator* (const Matrix4x4 &A, const Matrix4x4 &B); 
    142  
    143 // friends returning Vector3 
    144148Vector3 operator*(const Matrix4x4 &M, const Vector3 &v); 
    145149Vector3 RotateOnly(const Matrix4x4 &M, const Vector3 &v); 
     
    148152 
    149153 
    150 //} 
    151  
     154} 
    152155 
    153156 
Note: See TracChangeset for help on using the changeset viewer.