aboutsummaryrefslogtreecommitdiff
path: root/src/Utils/Point.cpp
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 19:04:34 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 19:16:14 +0100
commite6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 (patch)
tree129cf13c2f9b3eae54402300db4570815789a02a /src/Utils/Point.cpp
Initial commitHEADmaster
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;
+ }
+}