Revision 1025,
1.0 KB
checked in by gumbau, 18 years ago
(diff) |
namespace simplif
|
Line | |
---|
1 | #include <gfx/std.h>
|
---|
2 | #include <gfx/math/Mat3.h>
|
---|
3 |
|
---|
4 | using namespace simplif;
|
---|
5 |
|
---|
6 | Mat3 Mat3::identity(Vec3(1,0,0), Vec3(0,1,0), Vec3(0,0,1));
|
---|
7 | Mat3 Mat3::zero(Vec3(0,0,0), Vec3(0,0,0), Vec3(0,0,0));
|
---|
8 | Mat3 Mat3::unit(Vec3(1,1,1), Vec3(1,1,1), Vec3(1,1,1));
|
---|
9 |
|
---|
10 | Mat3 Mat3::diag(const Vec3& v)
|
---|
11 | {
|
---|
12 | Mat3 M(zero);
|
---|
13 |
|
---|
14 | M(0,0) = v[X];
|
---|
15 | M(1,1) = v[Y];
|
---|
16 | M(2,2) = v[Z];
|
---|
17 |
|
---|
18 | return M;
|
---|
19 | }
|
---|
20 |
|
---|
21 | Mat3 Mat3::extend(const Vec3& v)
|
---|
22 | {
|
---|
23 | return Mat3(v,v,v);
|
---|
24 | }
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | Mat3 Mat3::operator*(const Mat3& m) const
|
---|
29 | {
|
---|
30 | Mat3 A;
|
---|
31 | int i,j;
|
---|
32 |
|
---|
33 | for(i=0;i<3;i++)
|
---|
34 | for(j=0;j<3;j++)
|
---|
35 | A(i,j) = row[i]*m.col(j);
|
---|
36 |
|
---|
37 | return A;
|
---|
38 | }
|
---|
39 |
|
---|
40 | real Mat3::det()
|
---|
41 | {
|
---|
42 | return row[0] * (row[1] ^ row[2]);
|
---|
43 | }
|
---|
44 |
|
---|
45 | Mat3 Mat3::transpose()
|
---|
46 | {
|
---|
47 | return Mat3(col(0), col(1), col(2));
|
---|
48 | }
|
---|
49 |
|
---|
50 | Mat3 Mat3::adjoint()
|
---|
51 | {
|
---|
52 | return Mat3(row[1]^row[2],
|
---|
53 | row[2]^row[0],
|
---|
54 | row[0]^row[1]);
|
---|
55 | }
|
---|
56 |
|
---|
57 | real Mat3::inverse(Mat3& inv)
|
---|
58 | {
|
---|
59 | Mat3 A = adjoint();
|
---|
60 | real d = A.row[0] * row[0];
|
---|
61 |
|
---|
62 | if( d==0.0 )
|
---|
63 | return 0.0;
|
---|
64 |
|
---|
65 | inv = A.transpose() / d;
|
---|
66 | return d;
|
---|
67 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.