From 23687facf82e27c66b9e2689b1db10be361644de Mon Sep 17 00:00:00 2001 From: DarianTr Date: Fri, 31 May 2024 23:20:34 +0200 Subject: [PATCH] started reading the book --- convex_hull.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 convex_hull.cpp diff --git a/convex_hull.cpp b/convex_hull.cpp new file mode 100644 index 0000000..11ce931 --- /dev/null +++ b/convex_hull.cpp @@ -0,0 +1,30 @@ +#include "bits/stdc++.h" +using namespace std; + +bool left_side(pair &a, pair &b, pair &x) { + return (b.first - a.first)*(x.second - a.second) - (b.second - a.second) * (x.first - a.first) >= 0; +} + + +vector, pair>> slow_convex_hull(vector> &input) { + vector, pair>> 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"; +} +