From e6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:04:34 +0100 Subject: Initial commit --- src/Utils/Point.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Utils/Point.cpp (limited to 'src/Utils/Point.cpp') 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 +#include + +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; + } +} -- cgit v1.2.1