-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDC_CH.h
57 lines (44 loc) · 1.25 KB
/
DC_CH.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
/* ---------------------------------------------------------------------------
** This software is implemented as part of the course Computational Geometry
** (Fall 2014) at Aarhus Univerity Denmark.
**
** DC_CH.h
** Implementation of a divide-and-conquer convex algorithm.
**
** Author: Martin Storgaard and Konstantinos Mampentzidis
** -------------------------------------------------------------------------*/
#ifndef _DC_CH_H
#define _DC_CH_H
#include "CH.h"
class DC_CH : public CH {
private:
std::deque<point> findConvexHull(int left, int right, std::deque<point>& points);
int getRightMostPoint(std::deque<point>& ch){
int sz = ch.size();
int tmp = 0;
for(int i=0;i<sz;i++){
if(ch[i].x > ch[tmp].x) {
tmp = i;
}
}
return tmp;
}
int getLeftMostPoint(std::deque<point>& ch){
int sz = ch.size();
int tmp = 0;
for(int i=0;i<sz;i++){
if(ch[i].x < ch[tmp].x) {
tmp = i;
}
}
return tmp;
}
public:
const char* getName() {
return "DC_CH";
}
virtual void convexHull(std::deque<point>& points, const int numPoints, std::deque<point> &result);
DC_CH() {
}
};
#endif //_DC_CH_H