[Scummvm-git-logs] scummvm master -> e1bf5e2d436998503904e6217ba3e50eaeef9822
dreammaster
dreammaster at scummvm.org
Fri Sep 16 18:46:19 CEST 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e1bf5e2d43 TITANIC: Flesh out the FPoint class
Commit: e1bf5e2d436998503904e6217ba3e50eaeef9822
https://github.com/scummvm/scummvm/commit/e1bf5e2d436998503904e6217ba3e50eaeef9822
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-16T12:45:47-04:00
Commit Message:
TITANIC: Flesh out the FPoint class
Changed paths:
engines/titanic/star_control/fpoint.cpp
engines/titanic/star_control/fpoint.h
diff --git a/engines/titanic/star_control/fpoint.cpp b/engines/titanic/star_control/fpoint.cpp
index f3d7008..a282957 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 f2cef18..33181d9 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
More information about the Scummvm-git-logs
mailing list