aboutsummaryrefslogtreecommitdiff
path: root/src/Utils/Point.cpp
blob: 7dd96103d9f0c5c39abd8f10eb906b2927413960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
    }
}