Browse Source

Documented Matrix

Thomas Buck 10 years ago
parent
commit
63b504a8bf
2 changed files with 152 additions and 389 deletions
  1. 147
    315
      include/Matrix.h
  2. 5
    74
      src/Matrix.cpp

+ 147
- 315
include/Matrix.h View File

@@ -1,381 +1,213 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file include/Matrix.h
3
+ * \brief 3D Matrix
3 4
  *
4
- * Project : Freyja
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Matrix
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 3d Matrix in class form
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History ------------------------------------------------
17
- *
18
- * 2003.06.17:
19
- * Mongoose - Now in column order to match OpenGL user needs,
20
- *            use transpose() to get row order back  =)
21
- *
22
- * 2002.05.11:
23
- * Mongoose - Created, based on my mtk3d matrix
24
- ================================================================*/
25
-
5
+ * \author Mongoose
6
+ */
26 7
 
27 8
 #ifndef _MATRIX_H_
28 9
 #define _MATRIX_H_
29 10
 
30
-
31 11
 #include <MatMath.h>
32 12
 #include <Quaternion.h>
33 13
 #include <Vector3d.h>
34 14
 
35
-    ///////////////////////////////////////////////
36
-    // Multidim map for row order encoding       //
37
-    ///////////////////////////////////////////////
38
-    // 0,0 - 0;   0,1 - 1;   0,2 - 2;   0,3 - 3  //
39
-    // 1,0 - 4;   1,1 - 5;   1,2 - 6;   1,3 - 7  //
40
-    // 2,0 - 8;   2,1 - 9;   2,2 - 10;  2,3 - 11 //
41
-    // 3,0 - 12;  3,1 - 13;  3,2 - 14;  3,3 - 15 //
42
-    ///////////////////////////////////////////////
43
-
44
-    ///////////////////////////////////////////////
45
-    // Multidim map for column order encoding    //
46
-    ///////////////////////////////////////////////
47
-    // 0,0 - 0;   0,1 - 4;   0,2 - 8;   0,3 - 12 //
48
-    // 1,0 - 1;   1,1 - 5;   1,2 - 9;   1,3 - 13 //
49
-    // 2,0 - 2;   2,1 - 6;   2,2 - 10;  2,3 - 14 //
50
-    // 3,0 - 3;   3,1 - 7;   3,2 - 11;  3,3 - 15 //
51
-    ///////////////////////////////////////////////
52
-
53
-
54
-class Matrix
55
-{
56
- public:
57
-
58
-    ////////////////////////////////////////////////////////////
59
-    // Constructors
60
-    ////////////////////////////////////////////////////////////
61 15
 
16
+/*!
17
+ * \brief 3D Matrix
18
+ *
19
+ * Multidim map for row order encoding
20
+ *
21
+ *     ///////////////////////////////////////////////
22
+ *     // 0,0 - 0;   0,1 - 1;   0,2 - 2;   0,3 - 3  //
23
+ *     // 1,0 - 4;   1,1 - 5;   1,2 - 6;   1,3 - 7  //
24
+ *     // 2,0 - 8;   2,1 - 9;   2,2 - 10;  2,3 - 11 //
25
+ *     // 3,0 - 12;  3,1 - 13;  3,2 - 14;  3,3 - 15 //
26
+ *     ///////////////////////////////////////////////
27
+ *
28
+ * Multidim map for column order encoding
29
+ *
30
+ *     ///////////////////////////////////////////////
31
+ *     // 0,0 - 0;   0,1 - 4;   0,2 - 8;   0,3 - 12 //
32
+ *     // 1,0 - 1;   1,1 - 5;   1,2 - 9;   1,3 - 13 //
33
+ *     // 2,0 - 2;   2,1 - 6;   2,2 - 10;  2,3 - 14 //
34
+ *     // 3,0 - 3;   3,1 - 7;   3,2 - 11;  3,3 - 15 //
35
+ *     ///////////////////////////////////////////////
36
+ */
37
+class Matrix {
38
+public:
39
+
40
+    /*!
41
+     * \brief Constructs an object of Matrix
42
+     */
62 43
     Matrix();
63
-    /*------------------------------------------------------
64
-     * Pre  :
65
-     * Post : Constructs an object of Matrix
66
-     *
67
-     *-- History ------------------------------------------
68
-     *
69
-     * 2002.05.11:
70
-     * Mongoose - Created
71
-     ------------------------------------------------------*/
72 44
 
45
+    /*!
46
+     * \brief Constructs an object of Matrix
47
+     * \param mat Matrix as data source
48
+     */
73 49
     Matrix(matrix_t mat);
74
-    /*------------------------------------------------------
75
-     * Pre  :
76
-     * Post : Constructs an object of Matrix
77
-     *
78
-     *-- History ------------------------------------------
79
-     *
80
-     * 2002.05.11:
81
-     * Mongoose - Created
82
-     ------------------------------------------------------*/
83 50
 
51
+    /*!
52
+     * \brief Constructs an object of Matrix
53
+     * \param q Converts and assigns the Quaternion to the Matrix
54
+     */
84 55
     Matrix(Quaternion &q);
85
-    /*------------------------------------------------------
86
-     * Pre  :
87
-     * Post : Converts and asigns Q to a Matrix
88
-     *        returns quaternion as Matrix
89
-     *
90
-     *-- History ------------------------------------------
91
-     *
92
-     * 2002.05.08:
93
-     * Mongoose - Created
94
-     ------------------------------------------------------*/
95 56
 
57
+    /*!
58
+     * \brief Deconstructs an object of Matrix
59
+     */
96 60
     ~Matrix();
97
-    /*------------------------------------------------------
98
-     * Pre  : Matrix object is allocated
99
-     * Post : Deconstructs an object of Matrix
100
-     *
101
-     *-- History ------------------------------------------
102
-     *
103
-     * 2002.05.11:
104
-     * Mongoose - Created
105
-     ------------------------------------------------------*/
106
-
107
-    ////////////////////////////////////////////////////////////
108
-    // Public Accessors
109
-    ////////////////////////////////////////////////////////////
110 61
 
62
+    /*!
63
+     * \brief Returns this matrix copy
64
+     * \param mat target
65
+     */
111 66
     void getMatrix(matrix_t mat);
112
-    /*------------------------------------------------------
113
-     * Pre  :
114
-     * Post : Returns this matrix copy
115
-     *
116
-     *-- History ------------------------------------------
117
-     *
118
-     * 2002.05.08:
119
-     * Mongoose - Created
120
-     ------------------------------------------------------*/
121 67
 
68
+    /*!
69
+     * \brief Returns this matrix transposed
70
+     * \param mat target
71
+     */
122 72
     void getTransposeMatrix(matrix_t mat);
123
-    /*------------------------------------------------------
124
-     * Pre  :
125
-     * Post : Returns this matrix transposed
126
-     *
127
-     *-- History ------------------------------------------
128
-     *
129
-     * 2002.05.08:
130
-     * Mongoose - Created
131
-     ------------------------------------------------------*/
132 73
 
74
+    /*!
75
+     * \brief Returns this matrix inverted
76
+     * \param mat target
77
+     */
133 78
     bool getInvert(matrix_t mat);
134
-    /*------------------------------------------------------
135
-     * Pre  :
136
-     * Post : Returns this matrix inverted
137
-     *
138
-     *-- History ------------------------------------------
139
-     *
140
-     * 2002.05.08:
141
-     * Mongoose - Created
142
-     ------------------------------------------------------*/
143 79
 
80
+    /*!
81
+     * \brief Multiplies two matrices
82
+     * \param a first matrix
83
+     * \param b second matrix
84
+     * \returns resultant matrix
85
+     */
144 86
     Matrix multiply(const Matrix &a, const Matrix &b);
145
-    /*------------------------------------------------------
146
-     * Pre  : Multiplies 2 matrices
147
-     * Post : Returns resultant matrix
148
-     *
149
-     *-- History ------------------------------------------
150
-     *
151
-     * 2002.05.08:
152
-     * Mongoose - Created
153
-     ------------------------------------------------------*/
154 87
 
88
+    /*!
89
+     * \brief Multiplies v vector and this matrix
90
+     * \param v double[4] vector
91
+     * \param result where the result will be stored, may be same as v
92
+     */
155 93
     void multiply4d(double *v, double *result);
156
-    /*------------------------------------------------------
157
-     * Pre  : Multiplies <V> vector (double[4]) and <This> matrix
158
-     *
159
-     * Post : Returns <Result> vector,
160
-     *        <V> and <Result> maybe be the same vector
161
-     *
162
-     *-- History ------------------------------------------
163
-     *
164
-     * 2002.05.08:
165
-     * Mongoose - Created
166
-     ------------------------------------------------------*/
167 94
 
95
+    /*!
96
+     * \brief Multiplies v vector and this matrix
97
+     * \param v vector
98
+     * \param result where the result will be stored, may be same as v
99
+     */
168 100
     void multiply4v(vec4_t v, vec4_t result);
169
-    /*------------------------------------------------------
170
-     * Pre  : Multiplies <V> vector and <This> matrix
171
-     *
172
-     * Post : Returns <Result> vector,
173
-     *        <V> and <Result> maybe be the same vector
174
-     *
175
-     *-- History ------------------------------------------
176
-     *
177
-     * 2002.05.08:
178
-     * Mongoose - Created
179
-     ------------------------------------------------------*/
180 101
 
102
+    /*!
103
+     * \brief Multiplies v vector and this matrix
104
+     * \param v vector
105
+     * \param result where the result will be stored, may be same as v
106
+     */
181 107
     void multiply3v(vec3_t v, vec3_t result);
182
-    /*------------------------------------------------------
183
-     * Pre  : Multiplies <V> vector and <This> matrix
184
-     *
185
-     * Post : Returns <Result> vector,
186
-     *        <V> and <Result> maybe be the same vector
187
-     *
188
-     *-- History ------------------------------------------
189
-     *
190
-     * 2002.05.08:
191
-     * Mongoose - Created
192
-     ------------------------------------------------------*/
193 108
 
109
+    /*!
110
+     * \brief Prints matrix values to stdout
111
+     */
194 112
     void print();
195
-    /*------------------------------------------------------
196
-     * Pre  :
197
-     * Post : Prints matrix values to stdout
198
-     *
199
-     *-- History ------------------------------------------
200
-     *
201
-     * 2002.05.08:
202
-     * Mongoose - Created
203
-     ------------------------------------------------------*/
204 113
 
114
+    /*!
115
+     * \brief Is this matrix the identity matrix?
116
+     * \returns true if it is identity, false otherwise
117
+     */
205 118
     bool isIdentity();
206
-    /*------------------------------------------------------
207
-     * Pre  :
208
-     * Post : Is this matrix the identity matrix?
209
-     *
210
-     *-- History ------------------------------------------
211
-     *
212
-     * 2002.05.08:
213
-     * Mongoose - Created
214
-     ------------------------------------------------------*/
215 119
 
120
+    /*!
121
+     * \brief Multiplies a and this matrix
122
+     * \param a matrix to multiply with
123
+     * \returns resultant matrix
124
+     */
216 125
     Matrix operator *(const Matrix &a);
217
-    /*------------------------------------------------------
218
-     * Pre  : Multiplies A and this matrices
219
-     * Post : Returns resultant matrix
220
-     *
221
-     *-- History ------------------------------------------
222
-     *
223
-     * 2002.05.08:
224
-     * Mongoose - Created
225
-     ------------------------------------------------------*/
226 126
 
127
+    /*!
128
+     * \brief Multiply vector by this matrix
129
+     * \param v Vector to multiply with
130
+     * \returns resultant vector (mult)
131
+     */
227 132
     Vector3d operator *(Vector3d v);
228
-    /*------------------------------------------------------
229
-     * Pre  : <V> is vector to multiply by this matrix
230
-     * Post : Returns resultant vector ( mult )
231
-     *
232
-     *-- History ------------------------------------------
233
-     *
234
-     * 2002.05.08:
235
-     * Mongoose - Created
236
-     ------------------------------------------------------*/
237
-
238
-
239
-    ////////////////////////////////////////////////////////////
240
-    // Public Mutators
241
-    ////////////////////////////////////////////////////////////
242 133
 
134
+    /*!
135
+     * \brief Sets to identity matrix
136
+     */
243 137
     void setIdentity();
244
-    /*------------------------------------------------------
245
-     * Pre  :
246
-     * Post : Sets to identity matrix
247
-     *
248
-     *-- History ------------------------------------------
249
-     *
250
-     * 2002.05.08:
251
-     * Mongoose - Created
252
-     ------------------------------------------------------*/
253 138
 
139
+    /*!
140
+     * \brief S et the matrix
141
+     * \fixme dangerous, scary, boo!
142
+     * \param mat new matrix
143
+     */
254 144
     void setMatrix(matrix_t mat);
255
-    /*------------------------------------------------------
256
-     * Pre  :
257
-     * Post : Set the matrix ( dangerous, scary boo )
258
-     *
259
-     *-- History ------------------------------------------
260
-     *
261
-     * 2002.05.08:
262
-     * Mongoose - Created
263
-     ------------------------------------------------------*/
264 145
 
146
+    /*!
147
+     * \brief Rotate object in 3D space
148
+     * \param x x rotation in radians
149
+     * \param y y rotation in radians
150
+     * \param z z rotation in radians
151
+     */
265 152
     void rotate(vec_t x, vec_t y, vec_t z);
266
-    /*------------------------------------------------------
267
-     * Pre  : Radian input
268
-     * Post : Rotates object in 3 space
269
-     *
270
-     *-- History ------------------------------------------
271
-     *
272
-     * 2002.05.08:
273
-     * Mongoose - Created
274
-     ------------------------------------------------------*/
275 153
 
154
+    /*!
155
+     * \brief Rotate object in 3D space
156
+     * \param xyz rotation in radians
157
+     */
276 158
     void rotate(const vec_t *xyz);
277
-    /*------------------------------------------------------
278
-     * Pre  : Rotates object in 3 space, Radian input
279
-     * Post : Returns true on sucess
280
-     *
281
-     *-- History ------------------------------------------
282
-     *
283
-     * 2002.05.08:
284
-     * Mongoose - Created
285
-     ------------------------------------------------------*/
286 159
 
160
+    /*!
161
+     * \brief Scale object in 3D space
162
+     * \param x x scaling
163
+     * \param y y scaling
164
+     * \param z z scaling
165
+     */
287 166
     void scale(vec_t x, vec_t y, vec_t z);
288
-    /*------------------------------------------------------
289
-     * Pre  :
290
-     * Post : Scales object in 3 space
291
-     *
292
-     *-- History ------------------------------------------
293
-     *
294
-     * 2002.05.08:
295
-     * Mongoose - Created
296
-     ------------------------------------------------------*/
297 167
 
168
+    /*!
169
+     * \brief Scale object in 3D space
170
+     * \param xyz scaling factors
171
+     */
298 172
     void scale(const vec_t *xyz);
299
-    /*------------------------------------------------------
300
-     * Pre  :
301
-     * Post : Scales object in 3 space
302
-     *
303
-     *-- History ------------------------------------------
304
-     *
305
-     * 2002.05.08:
306
-     * Mongoose - Created
307
-     ------------------------------------------------------*/
308 173
 
174
+    /*!
175
+     * \brief Translate (move) object in 3D space
176
+     * \param x x translation
177
+     * \param y y translation
178
+     * \param z z translation
179
+     */
309 180
     void translate(vec_t x, vec_t y, vec_t z);
310
-    /*------------------------------------------------------
311
-     * Pre  :
312
-     * Post : Translates ( moves ) object in 3 space
313
-     *
314
-     *-- History ------------------------------------------
315
-     *
316
-     * 2002.05.08:
317
-     * Mongoose - Created
318
-     ------------------------------------------------------*/
319 181
 
182
+    /*!
183
+     * \brief Translate (move) object in 3D space
184
+     * \param xyz translations
185
+     */
320 186
     void translate(const vec_t *xyz);
321
-    /*------------------------------------------------------
322
-     * Pre  :
323
-     * Post : Translates ( moves ) object in 3 space
324
-     *
325
-     *-- History ------------------------------------------
326
-     *
327
-     * 2002.05.08:
328
-     * Mongoose - Created
329
-     ------------------------------------------------------*/
330 187
 
188
+    /*!
189
+     * \brief Transpose this matrix
190
+     */
331 191
     void transpose();
332
-    /*------------------------------------------------------
333
-     * Pre  :
334
-     * Post : Transpose this matrix
335
-     *
336
-     *-- History ------------------------------------------
337
-     *
338
-     * 2002.05.08:
339
-     * Mongoose - Created
340
-     ------------------------------------------------------*/
341
-
342
-    matrix_t mMatrix;      /* Data model, moved public for faster
343
-                                      external renderer feedback use */
344
-
345
- private:
346
-
347
-    ////////////////////////////////////////////////////////////
348
-    // Private Accessors
349
-    ////////////////////////////////////////////////////////////
350 192
 
193
+    matrix_t mMatrix; //!< Data model, moved public for faster external renderer feedback use
351 194
 
352
-    ////////////////////////////////////////////////////////////
353
-    // Private Mutators
354
-    ////////////////////////////////////////////////////////////
195
+private:
355 196
 
197
+    /*!
198
+     * \brief Copys value from source to dest
199
+     * \param source source
200
+     * \param dest destination
201
+     */
356 202
     void copy(matrix_t source, matrix_t dest);
357
-    /*------------------------------------------------------
358
-     * Pre  :
359
-     * Post : Copys value of source to dest
360
-     *
361
-     *-- History ------------------------------------------
362
-     *
363
-     * 2002.05.08:
364
-     * Mongoose - Created
365
-     ------------------------------------------------------*/
366 203
 
204
+    /*!
205
+     * \brief Multiplies matrices a and b. Neither a or b is also the result.
206
+     * \param a first matrix
207
+     * \param b second matrix
208
+     * \param result wil be set to resultant matrix value
209
+     */
367 210
     void multiply(const matrix_t a, const matrix_t b, matrix_t result);
368
-    /*------------------------------------------------------
369
-     * Pre  : Multiplies matrices a and b
370
-     *        Neither a or b is also the result
371
-     *
372
-     * Post : Sets resultant matrix value ( result )
373
-     *
374
-     *-- History ------------------------------------------
375
-     *
376
-     * 2002.05.08:
377
-     * Mongoose - Created
378
-     ------------------------------------------------------*/
379 211
 };
380 212
 
381 213
 #endif

+ 5
- 74
src/Matrix.cpp View File

@@ -1,46 +1,25 @@
1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file src/Matrix.cpp
3
+ * \brief 3D Matrix
3 4
  *
4
- * Project : Freyja
5
- * Author  : Terry 'Mongoose' Hendrix II
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Matrix
9
- * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 3d Matrix class
11
- *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2002.05.11:
19
- * Mongoose - Created
20
- =================================================================*/
5
+ * \author Mongoose
6
+ */
21 7
 
22 8
 #include <stdio.h>
23 9
 #include <math.h>
24 10
 
25 11
 #include <Matrix.h>
26 12
 
27
-
28
-////////////////////////////////////////////////////////////
29
-// Constructors
30
-////////////////////////////////////////////////////////////
31
-
32 13
 Matrix::Matrix()
33 14
 {
34 15
     setIdentity();
35 16
 }
36 17
 
37
-
38 18
 Matrix::Matrix(matrix_t m)
39 19
 {
40 20
     setMatrix(m);
41 21
 }
42 22
 
43
-
44 23
 Matrix::Matrix(Quaternion &q)
45 24
 {
46 25
     matrix_t m;
@@ -50,17 +29,10 @@ Matrix::Matrix(Quaternion &q)
50 29
     setMatrix(m);
51 30
 }
52 31
 
53
-
54 32
 Matrix::~Matrix()
55 33
 {
56 34
 }
57 35
 
58
-
59
-////////////////////////////////////////////////////////////
60
-// Public Accessors
61
-////////////////////////////////////////////////////////////
62
-
63
-
64 36
 bool Matrix::getInvert(matrix_t out)
65 37
 {
66 38
     matrix_t m;
@@ -189,13 +161,11 @@ bool Matrix::getInvert(matrix_t out)
189 161
 #undef SWAP_ROWS
190 162
 }
191 163
 
192
-
193 164
 void Matrix::getMatrix(matrix_t mat)
194 165
 {
195 166
     copy(mMatrix, mat);
196 167
 }
197 168
 
198
-
199 169
 void Matrix::getTransposeMatrix(matrix_t m)
200 170
 {
201 171
     m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
@@ -204,29 +174,24 @@ void Matrix::getTransposeMatrix(matrix_t m)
204 174
     m[12]= mMatrix[3]; m[13]= mMatrix[7]; m[14]= mMatrix[11]; m[15]=mMatrix[15];
205 175
 }
206 176
 
207
-
208 177
 Matrix Matrix::multiply(const Matrix &a, const Matrix &b)
209 178
 {
210 179
     Matrix c;
211 180
 
212
-
213 181
     multiply(a.mMatrix, b.mMatrix, c.mMatrix);
214 182
 
215 183
     return c;
216 184
 }
217 185
 
218
-
219 186
 Matrix Matrix::operator *(const Matrix &a)
220 187
 {
221 188
     return multiply(a, *this);
222 189
 }
223 190
 
224
-
225 191
 Vector3d Matrix::operator *(Vector3d v)
226 192
 {
227 193
     vec_t x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
228 194
 
229
-
230 195
 #ifdef COLUMN_ORDER
231 196
     // Column order
232 197
     return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
@@ -240,42 +205,35 @@ Vector3d Matrix::operator *(Vector3d v)
240 205
 #endif
241 206
 }
242 207
 
243
-
244 208
 void Matrix::multiply3v(vec3_t v, vec3_t result)
245 209
 {
246 210
     vec_t x = v[0], y = v[1], z = v[2];
247 211
 
248
-
249 212
     result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
250 213
     result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
251 214
     result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
252 215
 }
253 216
 
254
-
255 217
 void Matrix::multiply4d(double *v, double *result)
256 218
 {
257 219
     double x = v[0], y = v[1], z = v[2], w = v[3];
258 220
 
259
-
260 221
     result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
261 222
     result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
262 223
     result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
263 224
     result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
264 225
 }
265 226
 
266
-
267 227
 void Matrix::multiply4v(vec4_t v, vec4_t result)
268 228
 {
269 229
     vec_t x = v[0], y = v[1], z = v[2], w = v[3];
270 230
 
271
-
272 231
     result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
273 232
     result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
274 233
     result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
275 234
     result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
276 235
 }
277 236
 
278
-
279 237
 void Matrix::print()
280 238
 {
281 239
 #ifdef COLUMN_ORDER
@@ -293,7 +251,6 @@ void Matrix::print()
293 251
 #endif
294 252
 }
295 253
 
296
-
297 254
 bool Matrix::isIdentity()
298 255
 {
299 256
     // Hhhmm... floating point using direct comparisions
@@ -308,17 +265,11 @@ bool Matrix::isIdentity()
308 265
     return false;
309 266
 }
310 267
 
311
-
312
-////////////////////////////////////////////////////////////
313
-// Public Mutators
314
-////////////////////////////////////////////////////////////
315
-
316 268
 void Matrix::setMatrix(matrix_t mat)
317 269
 {
318 270
     copy(mat, mMatrix);
319 271
 }
320 272
 
321
-
322 273
 void Matrix::setIdentity()
323 274
 {
324 275
     mMatrix[ 0] = 1; mMatrix[ 1] = 0; mMatrix[ 2] = 0; mMatrix[ 3] = 0;
@@ -327,19 +278,16 @@ void Matrix::setIdentity()
327 278
     mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
328 279
 }
329 280
 
330
-
331 281
 void Matrix::scale(const vec_t *xyz)
332 282
 {
333 283
     scale(xyz[0], xyz[1], xyz[2]);
334 284
 }
335 285
 
336
-
337 286
 void Matrix::scale(vec_t sx, vec_t sy, vec_t sz)
338 287
 {
339 288
     matrix_t smatrix;
340 289
     matrix_t tmp;
341 290
 
342
-
343 291
     smatrix[ 0] = sx;smatrix[ 1] = 0; smatrix[ 2] = 0; smatrix[ 3] = 0;
344 292
     smatrix[ 4] = 0; smatrix[ 5] = sy;smatrix[ 6] = 0; smatrix[ 7] = 0;
345 293
     smatrix[ 8] = 0; smatrix[ 9] = 0; smatrix[10] = sz;smatrix[11] = 0;
@@ -349,18 +297,15 @@ void Matrix::scale(vec_t sx, vec_t sy, vec_t sz)
349 297
     multiply(tmp, smatrix, mMatrix);
350 298
 }
351 299
 
352
-
353 300
 void Matrix::rotate(const vec_t *xyz)
354 301
 {
355 302
     rotate(xyz[0], xyz[1], xyz[2]);
356 303
 }
357 304
 
358
-
359 305
 void Matrix::rotate(vec_t ax, vec_t ay, vec_t az)
360 306
 {
361 307
     matrix_t xmat, ymat, zmat, tmp, tmp2;
362 308
 
363
-
364 309
     xmat[ 0]=1;        xmat[ 1]=0;        xmat[ 2]=0;        xmat[ 3]=0;
365 310
     xmat[ 4]=0;        xmat[ 5]=cos(ax);  xmat[ 6]=sin(ax);  xmat[ 7]=0;
366 311
     xmat[ 8]=0;        xmat[ 9]=-sin(ax); xmat[10]=cos(ax);  xmat[11]=0;
@@ -381,18 +326,15 @@ void Matrix::rotate(vec_t ax, vec_t ay, vec_t az)
381 326
     multiply(tmp2, zmat, mMatrix);
382 327
 }
383 328
 
384
-
385 329
 void Matrix::translate(const vec_t *xyz)
386 330
 {
387 331
     translate(xyz[0], xyz[1], xyz[2]);
388 332
 }
389 333
 
390
-
391 334
 void Matrix::translate(vec_t tx, vec_t ty, vec_t tz)
392 335
 {
393 336
     matrix_t tmat, tmp;
394 337
 
395
-
396 338
     tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
397 339
     tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
398 340
     tmat[ 8]=0;  tmat[ 9]=0;  tmat[10]=1;  tmat[11]=0;
@@ -402,16 +344,6 @@ void Matrix::translate(vec_t tx, vec_t ty, vec_t tz)
402 344
     multiply(tmp, tmat, mMatrix);
403 345
 }
404 346
 
405
-
406
-////////////////////////////////////////////////////////////
407
-// Private Accessors
408
-////////////////////////////////////////////////////////////
409
-
410
-
411
-////////////////////////////////////////////////////////////
412
-// Private Mutators
413
-////////////////////////////////////////////////////////////
414
-
415 347
 void Matrix::copy(matrix_t source, matrix_t dest)
416 348
 {
417 349
 #ifdef FASTER_MATRIX
@@ -439,7 +371,6 @@ void Matrix::copy(matrix_t source, matrix_t dest)
439 371
 #endif
440 372
 }
441 373
 
442
-
443 374
 void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result)
444 375
 {
445 376
     /* Generated code for matrix mult

Loading…
Cancel
Save