source: trunk/VUT/GtpVisibilityPreprocessor/src/Matrix4x4.h @ 176

Revision 176, 3.1 KB checked in by bittner, 19 years ago (diff)

cosine sampling bug fixed

Line 
1#ifndef __MATRIX4x4_H
2#define __MATRIX4x4_H
3
4#include <iostream>
5using namespace std;
6
7class Vector3;
8
9
10
11class Matrix4x4
12{
13public:
14  float x[4][4]; // first index is column [x], the second is row [y]
15
16  Matrix4x4() { }
17
18  // here xXY - 'X' is row, and 'Y' is column - classical mathematical notation
19  Matrix4x4(float x11, float x12, float x13, float x14,
20           float x21, float x22, float x23, float x24,
21           float x31, float x32, float x33, float x34,
22           float x41, float x42, float x43, float x44);
23 
24
25  // Assignment operators
26  Matrix4x4& operator+= (const Matrix4x4 &A);   // add-to
27  Matrix4x4& operator-= (const Matrix4x4 &A);   // subtract-from
28  Matrix4x4& operator*= (const Matrix4x4 &A);   // multiply by matrix
29  Matrix4x4& operator*= (float A);              // scale by scalar
30
31  // Fundamental operations
32  int Invert();               // Invert the matrix .. returns 0 = regular
33  void Transpose();                             // Transpose the matrix
34  friend Matrix4x4 Invert(const Matrix4x4 &M);  // Invert a given matrix
35  friend Matrix4x4 Transpose(const Matrix4x4 &M);       // Transpose a given matrix
36
37  // Create various types of matrix.
38  friend Matrix4x4 IdentityMatrix();
39  friend Matrix4x4 ZeroMatrix();
40  friend Matrix4x4 TranslationMatrix(const Vector3 &Location);
41  friend Matrix4x4 RotationXMatrix(float Angle);
42  friend Matrix4x4 RotationYMatrix(float Angle);
43  friend Matrix4x4 RotationZMatrix(float Angle);
44  friend Matrix4x4 RotationYPRMatrix(float Yaw, float Pitch, float Roll);
45  // about axis 'axis' by angle 'Angle'
46  friend Matrix4x4 RotationAxisMatrix(const Vector3 &axis, float Angle);
47  // create the rotation matrix that rotates 'vecFrom' to 'vecTo'
48  friend Matrix4x4 RotationVectorsMatrix(const Vector3 &vecFrom,
49                                         const Vector3 &vecTo);
50 
51  friend Matrix4x4 ScaleMatrix(float X, float Y, float Z);
52  friend Matrix4x4 GenRotation(const Vector3 &x, const Vector3 &y,
53                             const Vector3 &z);
54  friend Matrix4x4 QuadricMatrix(float a, float b, float c, float d, float e,
55                              float f, float g, float h, float j, float k);
56  // returns matrix for transforming normal
57  friend Matrix4x4 NormalTransformMatrix(const Matrix4x4 &M);
58
59  friend Matrix4x4 MirrorX();
60  friend Matrix4x4 MirrorY();
61  friend Matrix4x4 MirrorZ();
62  friend Matrix4x4 RotationOnly(const Matrix4x4 &x);
63
64  // Binary operators
65  friend Matrix4x4 operator+ (const Matrix4x4 &A, const Matrix4x4 &B);
66  friend Matrix4x4 operator- (const Matrix4x4 &A, const Matrix4x4 &B);
67  friend Matrix4x4 operator* (const Matrix4x4 &A, float B);
68  friend Matrix4x4 operator* (const Matrix4x4 &A, const Matrix4x4 &B);
69
70  // friends returning Vector3
71  friend Vector3 operator*(const Matrix4x4 &M, const Vector3 &v);
72  friend Vector3 RotateOnly(const Matrix4x4 &M, const Vector3 &v);
73  friend Vector3 TransformNormal(const Matrix4x4 &M, const Vector3 &v);
74  friend Vector3 GetTranslation(const Matrix4x4 &M);
75
76  // Construct rotation description according VRML'97 specification
77  //  const CVector4D SFRotation(void) const;
78 
79  // Overloaded output operator.
80  friend ostream& operator<< (ostream &s, const Matrix4x4 &M);
81};
82
83
84
85#endif
Note: See TracBrowser for help on using the repository browser.