Skip to content

Commit

Permalink
TITANIC: star control, fmatrix refactoring
Browse files Browse the repository at this point in the history
renamed fn2->MatRProd and fn3->MatLProd.
They do post (R) and pre (L) multiplication.
  • Loading branch information
dafioram committed Aug 15, 2017
1 parent 970e4b2 commit 4bd4237
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions engines/titanic/star_control/fmatrix.cpp
Expand Up @@ -104,7 +104,7 @@ void FMatrix::set(const FVector &v) {
_row2.normalize();
}

void FMatrix::fn2(const FMatrix &m) {
void FMatrix::matRProd(const FMatrix &m) {
float x1 = _row1._y * m._row2._x + _row1._z * m._row3._x + _row1._x * m._row1._x;
float y1 = _row1._x * m._row1._y + m._row2._y * _row1._y + m._row3._y * _row1._z;
float z1 = _row1._x * m._row1._z + _row1._y * m._row2._z + _row1._z * m._row3._z;
Expand All @@ -120,7 +120,7 @@ void FMatrix::fn2(const FMatrix &m) {
_row3 = FVector(x3, y3, z3);
}

void FMatrix::fn3(const FMatrix &m) {
void FMatrix::matLProd(const FMatrix &m) {
float x1 = _row2._x * m._row1._y + m._row1._z * _row3._x + _row1._x * m._row1._x;
float y1 = m._row1._x * _row1._y + _row3._y * m._row1._z + _row2._y * m._row1._y;
float z1 = m._row1._x * _row1._z + m._row1._y * _row2._z + m._row1._z * _row3._z;
Expand Down
15 changes: 13 additions & 2 deletions engines/titanic/star_control/fmatrix.h
Expand Up @@ -85,8 +85,19 @@ class FMatrix {
*/
void set(const FVector &v);

void fn2(const FMatrix &m);
void fn3(const FMatrix &m);
/**
* Changes this matrix, A, to be C, where C=Am.
* Matrix m multiplies this matrix (A) on its Right.
* Matrix m is said to premultiply A (previous this matrix).
*/
void matRProd(const FMatrix &m);

/**
* Changes this matrix, A, to be C, where C=mA.
* Matrix m multiplies this matrix (A) on its Left.
* m is said to postmultiply A (previous this matrix).
*/
void matLProd(const FMatrix &m);

/**
* Returns true if the passed matrix equals this one
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/star_control/viewport.cpp
Expand Up @@ -156,7 +156,7 @@ void CViewport::fn12() {
FPose s2(s1, m3);

m1.copyFrom(s2);
_orientation.fn2(m1);
_orientation.matRProd(m1);
_flag = false;
}

Expand All @@ -181,7 +181,7 @@ void CViewport::reposition(double factor) {
}

void CViewport::fn15(const FMatrix &matrix) {
_orientation.fn3(matrix);
_orientation.matLProd(matrix);
_flag = false;
}

Expand Down

0 comments on commit 4bd4237

Please sign in to comment.