aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-09-16 12:45:47 -0400
committerPaul Gilbert2016-09-16 12:45:47 -0400
commite1bf5e2d436998503904e6217ba3e50eaeef9822 (patch)
tree2a49bc1dc32b74f860d01fe2da2631d1640edbf6 /engines/titanic
parent7360b651b1d07b7881e56c9c176afcb2a042c9b2 (diff)
downloadscummvm-rg350-e1bf5e2d436998503904e6217ba3e50eaeef9822.tar.gz
scummvm-rg350-e1bf5e2d436998503904e6217ba3e50eaeef9822.tar.bz2
scummvm-rg350-e1bf5e2d436998503904e6217ba3e50eaeef9822.zip
TITANIC: Flesh out the FPoint class
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/star_control/fpoint.cpp9
-rw-r--r--engines/titanic/star_control/fpoint.h19
2 files changed, 28 insertions, 0 deletions
diff --git a/engines/titanic/star_control/fpoint.cpp b/engines/titanic/star_control/fpoint.cpp
index f3d7008324..a2829572f8 100644
--- a/engines/titanic/star_control/fpoint.cpp
+++ b/engines/titanic/star_control/fpoint.cpp
@@ -21,8 +21,17 @@
*/
#include "titanic/star_control/fpoint.h"
+#include "common/algorithm.h"
namespace Titanic {
+void FPoint::normalize() {
+ double hyp = sqrt(_x * _x + _y * _y);
+ assert(hyp != 0.0);
+
+ double fraction = 1.0 / hyp;
+ _x *= fraction;
+ _y *= fraction;
+}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/fpoint.h b/engines/titanic/star_control/fpoint.h
index f2cef18ea5..33181d937b 100644
--- a/engines/titanic/star_control/fpoint.h
+++ b/engines/titanic/star_control/fpoint.h
@@ -34,6 +34,25 @@ public:
public:
FPoint() : _x(0), _y(0) {}
FPoint(double x, double y) : _x(x), _y(y) {}
+
+ bool operator==(const FPoint &p) const { return _x == p._x && _y == p._y; }
+ bool operator!=(const FPoint &p) const { return _x != p._x || _y != p._y; }
+
+ void operator+=(const FPoint &delta) {
+ _x += delta._x;
+ _y += delta._y;
+ }
+
+ void operator-=(const FPoint &delta) {
+ _x -= delta._x;
+ _y -= delta._y;
+ }
+
+ /**
+ * Normalises the X and Y coordinates as fractions relative to the
+ * value of the hypotenuse formed by a triangle from the origin (0,0)
+ */
+ void normalize();
};
} // End of namespace Titanic