From cb4d223780edfa42d4fb7d0c5feeb815f1ce014c Mon Sep 17 00:00:00 2001 From: karl Date: Mon, 23 Nov 2020 22:57:30 +0100 Subject: [PATCH] Add outline for Quickhull algorithm Mostly comments for now --- Makefile | 2 ++ Quickhull.cpp | 26 ++++++++++++++++++++++++++ Quickhull.h | 14 ++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 Quickhull.cpp create mode 100644 Quickhull.h diff --git a/Makefile b/Makefile index d4a36e5..3d01542 100644 --- a/Makefile +++ b/Makefile @@ -18,5 +18,7 @@ Display.o: Display.h Timing.o: Timing.h +Quickhull.o: Quickhull.h + clean : -rm *.o quickhull diff --git a/Quickhull.cpp b/Quickhull.cpp new file mode 100644 index 0000000..f92e5ca --- /dev/null +++ b/Quickhull.cpp @@ -0,0 +1,26 @@ + +#include "Quickhull.h" + +void Quickhull::get_hull(std::vector &input, std::vector &output) +{ + // Get leftmost and rightmost point + // Add them to the output. + + // Create a line from leftmost to rightmost + + // Sort points between left and right of that line + + // Call get_hull_with_line with the left points, as well as with the right points, and the line +} + +void Quickhull::get_hull_with_line(std::vector &input, std::vector &output, Point, Point) +{ + // If the input vector is empty, we're done + + // Find the point which is furthest away from the line, add it to the output + + // Build a triangle with these 3 points + // Remove points inside this triangle + + // Recursively call get_hull_with_line for each side of the triangle +} diff --git a/Quickhull.h b/Quickhull.h new file mode 100644 index 0000000..ea44b79 --- /dev/null +++ b/Quickhull.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "Point.h" + +class Quickhull +{ +public: + static void get_hull(std::vector &, std::vector &); + +private: + static void get_hull_with_line(std::vector &, std::vector &, Point, Point); +}; \ No newline at end of file