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 |
|
---|
20 | class Matrix2 {
|
---|
21 | public:
|
---|
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
|
---|
52 | Matrix2 DllExport RotateMatrix(float angle);
|
---|
53 | Matrix2 DllExport TransMatrix(const Point2& p);
|
---|
54 | Matrix2 DllExport ScaleMatrix(const Point2& s);
|
---|
55 |
|
---|
56 | Matrix2 DllExport Inverse(const Matrix2& M);
|
---|
57 |
|
---|
58 | // Transform point with matrix:
|
---|
59 | Point2 DllExport operator*(const Matrix2& A, const Point2& V);
|
---|
60 | Point2 DllExport operator*( const Point2& V, const Matrix2& A);
|
---|
61 | Point2 DllExport VectorTransform(const Matrix2& M, const Point2& V);
|
---|
62 |
|
---|
63 | // Printout
|
---|
64 | ostream DllExport &operator<< (ostream& s, const Matrix2& A);
|
---|
65 |
|
---|
66 | #endif
|
---|