You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
715 B
49 lines
715 B
#pragma once |
|
|
|
|
|
class Matrix |
|
{ |
|
public: |
|
Matrix() |
|
{ |
|
e11 = 1.0; e12 = 0.0; e13 = 0.0; e14 = 0.0; |
|
e21 = 0.0; e22 = 1.0; e23 = 0.0; e24 = 0.0; |
|
e31 = 0.0; e32 = 0.0; e33 = 1.0; e34 = 0.0; |
|
e41 = 0.0; e42 = 0.0; e43 = 0.0; e44 = 1.0; |
|
} |
|
|
|
union |
|
{ |
|
float e[4][4]; |
|
|
|
struct |
|
{ |
|
float e11, e12, e13, e14; |
|
float e21, e22, e23, e24; |
|
float e31, e32, e33, e34; |
|
float e41, e42, e43, e44; |
|
}; |
|
}; |
|
|
|
Matrix operator*(Matrix const& rhs) |
|
{ |
|
Matrix result; |
|
|
|
for (int row = 0; row < 4; ++row) |
|
{ |
|
for (int col = 0; col < 4; ++col) |
|
{ |
|
float sum = 0.0; |
|
|
|
for (int i = 0; i < 4; ++i) |
|
{ |
|
sum += e[row][i] * rhs.e[i][col]; |
|
} |
|
|
|
result.e[row][col] = sum; |
|
} |
|
} |
|
|
|
return result; |
|
} |
|
};
|
|
|