-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint_2D.h
71 lines (53 loc) · 1.27 KB
/
Point_2D.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <iostream>
#include <iomanip>
#include "Instrumentor.h"
typedef double coord_t;
class Point_2D
{
/**
* @author Evripidis Pavlidis
* @since 2020-5-12
*/
coord_t x, y;
public:
// We are ordering by value of y coord
bool operator <(const Point_2D& p) const {
return y < p.y || (y == p.y && x < p.x);
}
bool operator >(const Point_2D& p) const {
return y > p.y || (y == p.y && x > p.x);
}
bool operator == (const Point_2D& p) const {
return x == p.x && y == p.y;
}
bool operator <= (const Point_2D& p) const {
return y < p.y || (y == p.y && x <= p.x);
}
Point_2D() {
this->x = INFINITY;
this->y = INFINITY;
};
Point_2D(double x, double y) {
this->x = x;
this->y = y;
}
Point_2D(const Point_2D& other) {
this->x = other.x;
this->y = other.y;
}
friend std::ostream& operator<< (std::ostream& out, const Point_2D& point);
coord_t GetX();
coord_t GetY();
};
inline std::ostream& operator<< (std::ostream& out, const Point_2D& point)
{
out << "(" << point.x << ", " << point.y << ")"; /*std::fixed << std::setprecision(3) <<*/
return out;
}
inline coord_t Point_2D::GetX() {
return this->x;
}
inline coord_t Point_2D::GetY() {
return this->y;
}