aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorDavid Fioramonti2017-08-14 18:22:00 -0700
committerDavid Fioramonti2017-08-15 14:49:00 -0700
commite9ab6fcead6f2aaeb5a21e72a3a2e54eca661b9e (patch)
tree961f5c4c478129ebb47fe008e49022a19d2dba11 /engines/titanic
parent40b09ffd5414d3117a0e85b0cf3b3539ca015df4 (diff)
downloadscummvm-rg350-e9ab6fcead6f2aaeb5a21e72a3a2e54eca661b9e.tar.gz
scummvm-rg350-e9ab6fcead6f2aaeb5a21e72a3a2e54eca661b9e.tar.bz2
scummvm-rg350-e9ab6fcead6f2aaeb5a21e72a3a2e54eca661b9e.zip
TITANIC: fmatrix refactor, matrix product now non-member function
The matrix product doesn't change anything about the class so it doesn't need to be a member function. This way other functions can do multiplication of matrices.
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/star_control/fmatrix.cpp27
-rw-r--r--engines/titanic/star_control/fmatrix.h12
2 files changed, 22 insertions, 17 deletions
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index 04f9c889da..724b5975d4 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -25,6 +25,21 @@
namespace Titanic {
+//Non-member functions
+void matProd(const FMatrix &a, const FMatrix &m, FMatrix &C) {
+ C._row1._x = a._row1._y * m._row2._x + a._row1._z * m._row3._x + a._row1._x * m._row1._x;
+ C._row1._y = a._row1._x * m._row1._y + m._row2._y * a._row1._y + m._row3._y * a._row1._z;
+ C._row1._z = a._row1._x * m._row1._z + a._row1._y * m._row2._z + a._row1._z * m._row3._z;
+ C._row2._x = m._row1._x * a._row2._x + m._row3._x * a._row2._z + m._row2._x * a._row2._y;
+ C._row2._y = m._row3._y * a._row2._z + m._row1._y * a._row2._x + m._row2._y * a._row2._y;
+ C._row2._z = a._row2._z * m._row3._z + a._row2._x * m._row1._z + a._row2._y * m._row2._z;
+ C._row3._x = m._row1._x * a._row3._x + a._row3._z * m._row3._x + a._row3._y * m._row2._x;
+ C._row3._y = a._row3._y * m._row2._y + a._row3._z * m._row3._y + a._row3._x * m._row1._y;
+ C._row3._z = a._row3._x * m._row1._z + a._row3._y * m._row2._z + a._row3._z * m._row3._z;
+}
+
+//member functions
+
FMatrix::FMatrix() :
_row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) {
}
@@ -117,18 +132,6 @@ void FMatrix::set(const FVector &v) {
_row2.normalize();
}
-void FMatrix::matProd(const FMatrix &a, const FMatrix &m, FMatrix &C) {
- C._row1._x = a._row1._y * m._row2._x + a._row1._z * m._row3._x + a._row1._x * m._row1._x;
- C._row1._y = a._row1._x * m._row1._y + m._row2._y * a._row1._y + m._row3._y * a._row1._z;
- C._row1._z = a._row1._x * m._row1._z + a._row1._y * m._row2._z + a._row1._z * m._row3._z;
- C._row2._x = m._row1._x * a._row2._x + m._row3._x * a._row2._z + m._row2._x * a._row2._y;
- C._row2._y = m._row3._y * a._row2._z + m._row1._y * a._row2._x + m._row2._y * a._row2._y;
- C._row2._z = a._row2._z * m._row3._z + a._row2._x * m._row1._z + a._row2._y * m._row2._z;
- C._row3._x = m._row1._x * a._row3._x + a._row3._z * m._row3._x + a._row3._y * m._row2._x;
- C._row3._y = a._row3._y * m._row2._y + a._row3._z * m._row3._y + a._row3._x * m._row1._y;
- C._row3._z = a._row3._x * m._row1._z + a._row3._y * m._row2._z + a._row3._z * m._row3._z;
-}
-
void FMatrix::matRProd(const FMatrix &m) {
FMatrix C = FMatrix();
FMatrix A = FMatrix(_row1,_row2,_row3);
diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h
index 3970ac8eb2..f477500bad 100644
--- a/engines/titanic/star_control/fmatrix.h
+++ b/engines/titanic/star_control/fmatrix.h
@@ -92,11 +92,6 @@ public:
void set(const FVector &v);
/**
- * Puts the matrix product between a and m in C, C = am
- */
- void matProd(const FMatrix &a, const FMatrix &m, FMatrix &C);
-
- /**
* Changes this matrix, A, to be C, where C=Am. Matrix m multiplies this matrix (A) on its Right.
* m is said to premultiply A (the previous this matrix).
*/
@@ -132,6 +127,13 @@ public:
}
};
+/**
+* Puts the matrix product between a and m in C, C = am
+* Called by MatLProd and MatLProd
+* Caller must preallocate output matrix
+*/
+void matProd(const FMatrix &a, const FMatrix &m, FMatrix &C);
+
} // End of namespace Titanic
#endif /* TITANIC_FMATRIX_H */