source: golgotha/src/maxtool/sdk_inc/matrix2.h @ 80

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.0 KB
Line 
1/**********************************************************************
2 *<
3        FILE: matrix2.h
4
5        DESCRIPTION: Class definitions for Matrix2
6
7        CREATED BY: Dan Silva
8
9        HISTORY:
10
11 *>     Copyright (c) 1994, All Rights Reserved.
12 **********************************************************************/
13
14#ifndef __MATRIX2__
15
16#define __MATRIX2_
17
18#include "point2.h"
19
20class Matrix2 {
21public:
22        float m[3][2];
23
24        // Constructors
25        Matrix2(){}      // NO INITIALIZATION done in this constructor!! (can use Zero or IdentityMatrix)
26        DllExport Matrix2(float (*fp)[2]);
27       
28        // Assignment operators
29        DllExport Matrix2& operator-=( const Matrix2& M);
30        DllExport Matrix2& operator+=( const Matrix2& M);
31        DllExport Matrix2& operator*=( const Matrix2& M);       // Matrix multiplication
32
33        // Conversion function
34        operator float*() { return(&m[0][0]); }
35
36        // Initialize matrix
37        DllExport void IdentityMatrix();        // Set to the Identity Matrix
38        DllExport void Zero();          // Set all elements to 0
39
40        // Apply Incremental transformations to this matrix
41        DllExport void Translate(const Point2& p);
42        DllExport void Rotate(float angle); 
43        DllExport void Scale(const Point2& s);
44               
45        // Binary operators             
46        DllExport Matrix2 Matrix2::operator*(const Matrix2& B) const;   
47        DllExport Matrix2 Matrix2::operator+(const Matrix2& B) const;
48        DllExport Matrix2 Matrix2::operator-(const Matrix2& B) const;
49        };
50
51// Build new matrices for transformations
52Matrix2 DllExport RotateMatrix(float angle);   
53Matrix2 DllExport TransMatrix(const Point2& p);
54Matrix2 DllExport ScaleMatrix(const Point2& s);
55 
56Matrix2 DllExport Inverse(const Matrix2& M);
57
58// Transform point with matrix:
59Point2 DllExport operator*(const Matrix2& A, const Point2& V);
60Point2 DllExport operator*( const Point2& V, const Matrix2& A);
61Point2 DllExport VectorTransform(const Matrix2& M, const Point2& V);
62
63// Printout
64ostream DllExport &operator<< (ostream& s, const Matrix2& A);
65
66#endif
Note: See TracBrowser for help on using the repository browser.