# source:golgotha/src/maxtool/sdk_inc/matrix33.h@80Tweet

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
• Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
• Property svn:keywords set to `Id`
File size: 2.3 KB
RevLine
[80]1/**********************************************************************
2 *<
3        FILE: matrix33.h
4
5        DESCRIPTION: Class definitions for Matrix33
6
7        CREATED BY: Dan Silva
8
9        HISTORY:
10
12 **********************************************************************/
13#ifndef _MATRIX33_H
14
15#define _MATRIX33_H
16
17#include "point3.h"
18
19class Matrix33 {
20public:
21        float m[4][3];
22
23        // Constructors
24        Matrix33(){}     // NO INITIALIZATION done in this constructor!!
25                                 // (can use IdentityMatrix)
26        DllExport Matrix33(float (*fp)[3]);
27
28        // Assignment operators
29        DllExport Matrix33& operator-=( const Matrix33& M);
30        DllExport Matrix33& operator+=( const Matrix33& M);
31        DllExport Matrix33& operator*=( const Matrix33& M);     // Matrix multiplication
32
33        // Conversion function
34        operator float*() { return(&m[0][0]); }
35
36        // Operations on matrix
37        DllExport void IdentityMatrix();                // Make into the Identity Matrix
38        DllExport void Zero();          // set all elements to 0
39
40        // null out the rotation part;
41        DllExport void NoRot();
42        // null out the scale part;
43        DllExport void NoScale();
44
45        // Access i-th row as Point3 for read or assignment:
46        Point3& operator[](int i) { return((Point3&)(*m[i])); }
47        Point3& operator[](int i) const { return((Point3&)(*m[i])); }
48
49        // Apply Incremental transformations to this matrix
50        DllExport void RotateX(float angle);
51        DllExport void RotateY(float angle);
52        DllExport void RotateZ(float angle);
53        DllExport void Scale(const Point3& s);
54
55        DllExport Matrix33 operator*(const Matrix33&) const;
56        DllExport Matrix33 operator+(const Matrix33&) const;
57        DllExport Matrix33 operator-(const Matrix33&) const;
58
59        };
60
61
62// Build new matrices for transformations
63
64Matrix33 DllExport Inverse(const Matrix33& M);  // return Inverse of matrix
65
66// These two versions of transforming a point with a matrix do the same thing,
67// regardless of the order of operands (linear algebra rules notwithstanding).
68Point3 DllExport operator*(const Matrix33& A, const Point3& V); // Transform Point with matrix
69Point3 DllExport operator*(const Point3& V, const Matrix33& A); // Transform Point with matrix
70
71ostream DllExport &operator<< (ostream& s, const Matrix33& A);
72
73#endif // define _MATRIX33_H
Note: See TracBrowser for help on using the repository browser.