aboutsummaryrefslogtreecommitdiff
path: root/src/Utils/Point.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils/Point.cpp')
-rw-r--r--src/Utils/Point.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Utils/Point.cpp b/src/Utils/Point.cpp
new file mode 100644
index 0000000..7dd9610
--- /dev/null
+++ b/src/Utils/Point.cpp
@@ -0,0 +1,33 @@
+#include <cmath>
+#include <HyperNeat/Utils/Point.hpp>
+
+using namespace std;
+using namespace hyperneat;
+
+Point::Point(double x, double y)
+ : _x(x), _y(y)
+{}
+
+double
+Point::distance(const Point& other) const
+{
+ double x = _x - other._x;
+ double y = _y - other._y;
+
+ return sqrt(x * x + y * y);
+}
+
+bool
+Point::operator==(const Point& other) const{
+ return (_x == other._x) && (_y == other._y);
+}
+
+bool
+Point::operator<(const Point& other) const
+{
+ if (_x == other._x) {
+ return _y < other._y;
+ } else {
+ return _x < other._x;
+ }
+}