diff options
-rw-r--r-- | engines/titanic/star_control/daffine.cpp | 13 | ||||
-rw-r--r-- | engines/titanic/star_control/daffine.h | 18 | ||||
-rw-r--r-- | engines/titanic/star_control/dvector.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/star_control/dvector.h | 3 |
4 files changed, 24 insertions, 13 deletions
diff --git a/engines/titanic/star_control/daffine.cpp b/engines/titanic/star_control/daffine.cpp index a7bed770c7..56c705b6a5 100644 --- a/engines/titanic/star_control/daffine.cpp +++ b/engines/titanic/star_control/daffine.cpp @@ -29,7 +29,7 @@ namespace Titanic { DAffine *DAffine::_static; DAffine::DAffine() : - _col1(0.0, 0.0, 0.0), _col2(0.0, 0.0, 0.0), _col3(0.0, 0.0, 0.0) { + _col1(0.0, 0.0, 0.0), _col2(0.0, 0.0, 0.0), _col3(0.0, 0.0, 0.0), _col4(0.0, 0.0, 0.0) { } DAffine::DAffine(int mode, const DVector &src) { @@ -55,8 +55,8 @@ DAffine::DAffine(int mode, const DVector &src) { } } -DAffine::DAffine(Axis axis, double amount) { - setRotationMatrix(axis, amount); +DAffine::DAffine(Axis axis, double angleDeg) { + setRotationMatrix(axis, angleDeg); } DAffine::DAffine(const FMatrix &src) { @@ -74,10 +74,9 @@ void DAffine::deinit() { _static = nullptr; } -void DAffine::setRotationMatrix(Axis axis, double amount) { - const double FACTOR = 0.0174532925199433; - double sinVal = sin(amount * FACTOR); - double cosVal = cos(amount * FACTOR); +void DAffine::setRotationMatrix(Axis axis, double angleDeg) { + double sinVal = sin(angleDeg * Deg2Rad); + double cosVal = cos(angleDeg * Deg2Rad); switch (axis) { case X_AXIS: diff --git a/engines/titanic/star_control/daffine.h b/engines/titanic/star_control/daffine.h index 50f8b9580b..50450b9427 100644 --- a/engines/titanic/star_control/daffine.h +++ b/engines/titanic/star_control/daffine.h @@ -51,18 +51,30 @@ public: public: DAffine(); DAffine(int mode, const DVector &src); - DAffine(Axis axis, double amount); + DAffine(Axis axis, double angleDeg); DAffine(const FMatrix &src); /** - * Sets up a matrix for rotating on a given axis by a given amount + * Sets up an affine matrix for rotating on a given axis by an amount in degrees */ - void setRotationMatrix(Axis axis, double amount); + void setRotationMatrix(Axis axis, double angleDeg); + /** + * Return the Inverse of this Daffine + */ DAffine inverseTransform() const; + /** + * Change this Daffine to have its first three columns be the src matrix + * and the 4rth column to be (three) zeros + */ void loadTransform(const CMatrixTransform &src); + /** + * Do the affine product between this Daffine on the left + * and the m Daffine matrix on the right. This is product is NOT the same + * as multiplying two matrices of dimensions 4x4. + */ DAffine compose(const DAffine &m); }; diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp index 1f873b5764..9f35ff6b67 100644 --- a/engines/titanic/star_control/dvector.cpp +++ b/engines/titanic/star_control/dvector.cpp @@ -26,9 +26,6 @@ namespace Titanic { -const double Rad2Deg = 180.0 / M_PI; -const double Deg2Rad = 1.0 / Rad2Deg; - double DVector::normalize() { double hyp = sqrt(_x * _x + _y * _y + _z * _z); assert(hyp); diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h index eda69f9b81..bff271dd6f 100644 --- a/engines/titanic/star_control/dvector.h +++ b/engines/titanic/star_control/dvector.h @@ -27,6 +27,9 @@ namespace Titanic { +const double Rad2Deg = 180.0 / M_PI; +const double Deg2Rad = 1.0 / Rad2Deg; + class DAffine; /** |