-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog1.h
33 lines (30 loc) · 937 Bytes
/
prog1.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
#ifndef PROG1_H
#define PROG1_H
#include <vector>
#include <cmath>
// Custom Point struct for ease of use
struct Point
{
public:
// Custom comparator between Points
static bool hullcmp(Point &a, Point &b) {
return a.x < b.x;
}
double x, y;
int index;
Point() : x(0.0), y(0.0), index(0) {};
Point(double x, double y, int index) : x(x), y(y), index(index) {};
};
// Custom comparator class for set of Points
struct counterClockwise {
double getCounterClockwiseAngle(const Point &point) const {
// Find counter clockwise angle
double angle = -1 * atan2(point.x, point.y);
return angle;
}
// Sort with smallest counter clockwise angle -> largest counter clockwise angle
bool operator() (const Point &lhs, const Point &rhs) const {
return getCounterClockwiseAngle(lhs) < getCounterClockwiseAngle(rhs);
}
};
#endif