5 #ifndef COMPUTGEOALGOS_ORIGIN_H 6 #define COMPUTGEOALGOS_ORIGIN_H 9 #include <bits/stdc++.h> 11 #define ull unsigned long long 17 #define ANTICLOCKWISE 3 25 dist = sqrt(pow((fpoint.first-spoint.first),2.0) + pow((fpoint.second-spoint.second),2.0));
33 int orientation(pair<double, double> a, pair<double, double> b, pair<double, double> c) {
35 dif = (b.second - a.second)*(c.first-b.first) - (b.first-a.first)* (c.second - b.second);
36 cout <<
"Difference in Slopes " << dif<<endl;
38 cout <<
"COLLINEAR\n";
40 }
else if (dif > 0 ) {
41 cout <<
"CLOCKWISE\n";
44 cout <<
"ANTICLOCKWISE\n";
52 bool orderedSort(pair<double,double> &f, pair<double,double> &s) {
54 if(f.first < s.first) {
57 if (f.first > s.first) {
60 return f.second<s.second;
66 bool orderedYSort(pair<double,double> &f, pair<double,double> &s) {
67 if(f.second < s.second) {
70 if (f.second > s.second) {
73 return f.first<s.first;
80 pair<double ,double >
P0;
87 bool orderByPolar(pair<double,double> &p1, pair<double,double> &p2){
89 cout <<
"comparing " <<
"(" <<
P0.first <<
", " <<
P0.second <<
")" <<
" " 90 <<
"(" << p1.first <<
", " << p1.second <<
")" <<
" " 91 <<
"(" << p2.first <<
", " << p2.second <<
")" <<endl;
92 cout <<
" The orientation value is " << oValue << endl;
105 cout << s << v.size() << endl;
107 cout << v[i].first <<
" " << v[i].second <<endl;
113 vector<pair<double, double> >
getData(
char *filename) {
114 vector<pair<double, double> > input;
117 in_file.open(filename);
118 while (in_file.is_open()) {
121 while(in_file >> a >> b) {
128 #endif //COMPUTGEOALGOS_ORIGIN_H bool orderByPolar(pair< double, double > &p1, pair< double, double > &p2)
Function to order with respect to polar Coordinates.
Definition: origin.h:87
double calcEuclidDistance(pair< double, double > fpoint, pair< double, double > spoint)
Euclidean Distance.
Definition: origin.h:23
int orientation(pair< double, double > a, pair< double, double > b, pair< double, double > c)
Orientation.
Definition: origin.h:33
pair< double,double > P0
a double value which stores the centre about which polar ordering is to be done
Definition: origin.h:80
#define COLLINEAR
Definition: origin.h:15
vector< pair< double, double > > getData(char *filename)
Extract Data from Input File.
Definition: origin.h:113
bool orderedYSort(pair< double, double > &f, pair< double, double > &s)
Comparator Function Sort by y coordinate.
Definition: origin.h:66
vector< int > indices
Definition: origin.h:19
#define mp
Definition: origin.h:13
void printVectorData(int len, vector< pair< double, double > > v, string s)
Print Function.
Definition: origin.h:103
#define ANTICLOCKWISE
Definition: origin.h:17
#define CLOCKWISE
Definition: origin.h:16
bool orderedSort(pair< double, double > &f, pair< double, double > &s)
Comparator Function.
Definition: origin.h:52