CGR Localization
 All Classes Namespaces Files Functions Variables Macros Pages
grahams_scan.h
1 #include <vector>
2 #include <math.h>
3 #include "geometry.h"
4 #include <sstream>
5 #include "util.h"
6 #include "timer.h"
7 
8 #ifndef GRAHAMS_SCAN_H
9 #define GRAHAMS_SCAN_H
10 
11 using namespace std;
12 
14 
15 public:
16  struct point
17  {
18  vector2f loc;
19  double angle;
20  point *next; //POINTER TO NEXT NODE IN THE LIST
21  point *prev; //POINTER TO PREVIOUS NODE IN THE LIST
22  };
23 
24 private:
25  int NumPoints;
26  point* firstPoint; //POINTER TO MIN POINT IN DOUBLELY LINKED LIST
27 
28 public:
29  GrahamsScan();
30  ~GrahamsScan();
31  vector<vector2f> run(vector< vector2f > points);
32  void grahamScan(point* P);//ACTUAL GRAHAM'S SCAN PROCEDURE
33 
34 private:
35  bool isConvexPoint(point *P); //TEST POINT FOR CONVEXITY
36  void addPoint(GrahamsScan::point &Point); //ADDS POINT TO DOUBLELY LINKED LIST (USED DURING SORTING)
37  double findAngle(vector2f &loc1, vector2f &loc2); //FIND ANGLE GIVEN TWO POINTS
38  void deleteAllPoints();
39 };
40 
41 #endif //GRAHAMS_SCAN_H