started reading the book

This commit is contained in:
2024-05-31 23:20:34 +02:00
parent 5385967d9d
commit 23687facf8

30
convex_hull.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "bits/stdc++.h"
using namespace std;
bool left_side(pair<int, int> &a, pair<int, int> &b, pair<int, int> &x) {
return (b.first - a.first)*(x.second - a.second) - (b.second - a.second) * (x.first - a.first) >= 0;
}
vector<pair<pair<int, int>, pair<int, int>>> slow_convex_hull(vector<pair<int, int>> &input) {
vector<pair<pair<int, int>, pair<int, int>>> output;
for (int i{}; i < input.size(); i++) {
for (int j = i +1; j < input.size(); j++) {
bool valid = true;
for (int k{}; k < input.size(); k++) {
if (left_side(input[i], input[j], input[k])) {
valid = false;
}
}
if (valid) {
output.emplace_back(input[i], input[j]);
}
}
}
return output;
}
int main() {
cout << "test";
}