Go to the source code of this file.
|
| vector< pair< double, double > > | convex_hull (vector< pair< double, double > > points) |
| | Upper Hull and Lower Hull Algorithm More...
|
| |
| set< pair< double, double > > | execAndrews (vector< pair< double, double > > Points) |
| | Complete Execution of Andrews Monotone Chain More...
|
| |
| vector<pair<double,double > > convex_hull |
( |
vector< pair< double, double > > |
points | ) |
|
Upper Hull and Lower Hull Algorithm
- In case of upper hull formation we move from last element to the first and vice versa for lower hull.
- Now we remove those points that are either anti-clockwise or collinear because being anticlockwise we are actually using an interior point in such cases.
- After forming the hull remove the last point of each list (it's the same as the first point of the other list)
16 int n = points.size();
18 vector<pair<double, double> > hull;
20 for (
int i = 0; i < n; ++i) {
23 cout <<
"popping out\n";
32 cout <<
"-------------------COUNTER VALUE AFTER LOWER HULL:" << counter <<endl;
34 for (
int i = n-2, t = counter+1; i >= 0; i--) {
37 cout <<
"popping out\n";
46 cout <<
"-------------------COUNTER VALUE AFTER UPPER HULL:" << counter <<endl;
47 hull.resize(counter-1);
int orientation(pair< double, double > a, pair< double, double > b, pair< double, double > c)
Orientation.
Definition: origin.h:33
vector< int > indices
Definition: origin.h:19
#define CLOCKWISE
Definition: origin.h:16
| set<pair<double, double> > execAndrews |
( |
vector< pair< double, double > > |
Points | ) |
|
Complete Execution of Andrews Monotone Chain
- Sort the array by their x-coordinate. If that's equal then compare y-coordinate this is compared in origin.h header file.
- The next part involves getting upper and lower convex hull
- The final set that is formed is just to remove any existing duplicate points in the vector
61 cout <<
"Executing Andrews Algorithm\n---\n";
62 vector<pair<double, double> > tentative_hull;
63 vector<pair<double, double> > L_upper,L_lower;
65 len = int(Points.size());
75 set<pair<double ,double> > f_convex_hull;
76 int LU_len = tentative_hull.size();
79 out_file.open(
"output.ch");
81 out_file << len <<
" " << LU_len <<
"\n";
82 cout <<
"Elements in convex hull:" << LU_len <<endl;
83 for(
int i=0;i < len;i++) {
84 out_file << Points[i].first <<
" " << Points[i].second <<
" 0\n";
86 for(
int i=0;i<LU_len;i++) {
87 f_convex_hull.insert(tentative_hull[i]);
91 vector<int>::iterator it_set;
93 out_file << *it_set <<
" ";
vector< int > indices
Definition: origin.h:19
vector< pair< double, double > > convex_hull(vector< pair< double, double > > points)
Upper Hull and Lower Hull Algorithm
Definition: Andrews.h:14
bool orderedSort(pair< double, double > &f, pair< double, double > &s)
Comparator Function.
Definition: origin.h:52