Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/********************************************************************************
* *
* S i n g l e - P r e c i s i o n 3 x 3 M a t r i x *
* *
*********************************************************************************
* Copyright (C) 2003,2006 by Jeroen van der Zijp. All Rights Reserved. *
*********************************************************************************
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*********************************************************************************
* $Id: FXMat3f.h 2344 2006-02-12 21:19:36Z lyle $ *
********************************************************************************/
#ifndef FXMAT3F_H
#define FXMAT3F_H
namespace FX {
class FXQuatf;
/// Single-precision 3x3 matrix
class FXAPI FXMat3f {
protected:
FXVec3f m[3];
public:
/// Default constructor
FXMat3f(){}
/// Initialize matrix from another matrix
FXMat3f(const FXMat3f& other);
/// Initialize matrix from scalar
FXMat3f(FXfloat w);
/// Initialize matrix from components
FXMat3f(FXfloat a00,FXfloat a01,FXfloat a02,
FXfloat a10,FXfloat a11,FXfloat a12,
FXfloat a20,FXfloat a21,FXfloat a22);
/// Initialize matrix from three vectors
FXMat3f(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c);
/// Initialize matrix from quaternion
FXMat3f(const FXQuatf& quat);
/// Assignment
FXMat3f& operator=(const FXMat3f& other);
FXMat3f& operator=(FXfloat w);
/// Set value from another matrix
FXMat3f& set(const FXMat3f& other);
/// Set value from scalar
FXMat3f& set(FXfloat w);
/// Set value from components
FXMat3f& set(FXfloat a00,FXfloat a01,FXfloat a02,
FXfloat a10,FXfloat a11,FXfloat a12,
FXfloat a20,FXfloat a21,FXfloat a22);
/// Set value from three vectors
FXMat3f& set(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c);
/// Set value from quaternion
FXMat3f& set(const FXQuatf& quat);
/// Assignment operators
FXMat3f& operator+=(const FXMat3f& w);
FXMat3f& operator-=(const FXMat3f& w);
FXMat3f& operator*=(FXfloat w);
FXMat3f& operator*=(const FXMat3f& w);
FXMat3f& operator/=(FXfloat w);
/// Indexing
FXVec3f& operator[](FXint i){return m[i];}
const FXVec3f& operator[](FXint i) const {return m[i];}
/// Conversion
operator FXfloat*(){return m[0];}
operator const FXfloat*() const {return m[0];}
/// Unary minus
FXMat3f operator-() const;
/// Matrix and matrix
FXMat3f operator+(const FXMat3f& w) const;
FXMat3f operator-(const FXMat3f& w) const;
FXMat3f operator*(const FXMat3f& w) const;
/// Multiply matrix and vector
FXVec3f operator*(const FXVec3f& v) const;
FXVec2f operator*(const FXVec2f& v) const;
/// Matrix and scalar
friend FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a);
friend FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x);
friend FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x);
friend FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a);
/// Set identity matrix
FXMat3f& eye();
/// Multiply by rotation of phi
FXMat3f& rot(FXfloat c,FXfloat s);
FXMat3f& rot(FXfloat phi);
/// Multiply by translation
FXMat3f& trans(FXfloat tx,FXfloat ty);
/// Multiply by scaling
FXMat3f& scale(FXfloat sx,FXfloat sy);
FXMat3f& scale(FXfloat s);
/// Determinant
FXfloat det() const;
/// Transpose
FXMat3f transpose() const;
/// Invert
FXMat3f invert() const;
/// Save to a stream
friend FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m);
/// Load from a stream
friend FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m);
};
extern FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a);
extern FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x);
extern FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x);
extern FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a);
extern FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m);
extern FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m);
}
#endif