File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ Matrix makeMatrixTranslation(const Vector v) {
31
31
};
32
32
}
33
33
34
+ Matrix makeMatrixScale (const float s ) {
35
+
36
+ return (Matrix ) {
37
+ s , 0 , 0 , 0 ,
38
+ 0 , s , 0 , 0 ,
39
+ 0 , 0 , s , 0 ,
40
+ 0 , 0 , 0 , 1
41
+ };
42
+ }
43
+
34
44
Matrix makeMatrixAxisAngle (const Vector axis , const float angle ) {
35
45
36
46
float length = vLength (axis );
@@ -290,5 +300,12 @@ Matrix mInversed(const Matrix matrix) {
290
300
return returnValue ;
291
301
}
292
302
303
+ float mScale (const Matrix matrix ) {
293
304
294
-
305
+ return powf (
306
+ matrix .values [0 ][0 ] * (matrix .values [1 ][1 ] * matrix .values [2 ][2 ] - matrix .values [1 ][2 ] * matrix .values [2 ][1 ])
307
+ - matrix .values [0 ][1 ] * (matrix .values [1 ][0 ] * matrix .values [2 ][2 ] - matrix .values [1 ][2 ] * matrix .values [2 ][0 ])
308
+ + matrix .values [0 ][2 ] * (matrix .values [1 ][0 ] * matrix .values [2 ][1 ] - matrix .values [1 ][1 ] * matrix .values [2 ][0 ]),
309
+ 1 /3.0
310
+ );
311
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ typedef struct {
11
11
Matrix makeMatrixZero ();
12
12
Matrix makeMatrixIdentity ();
13
13
Matrix makeMatrixTranslation (const Vector v );
14
+ Matrix makeMatrixScale (const float s );
14
15
Matrix makeMatrixAxisAngle (const Vector axis , const float angle );
15
16
16
17
bool mEqual (const Matrix a , const Matrix b );
@@ -24,4 +25,6 @@ Ray mrMul(const Matrix matrix, const Ray ray);
24
25
25
26
Matrix mInversed ();
26
27
28
+ float mScale (const Matrix matrix );
29
+
27
30
#endif // MATRIX_H
You can’t perform that action at this time.
0 commit comments