You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Convex Hull/README.md
+14-4
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,23 @@
1
1
# Convex Hull
2
2
3
-
There are multiple Convex Hull algorithms. This particular implementation uses the Quickhull algorithm.
3
+
Given a group of points on a plane. The Convex Hull algorithm calculates the shape (made up from the points itself) containing all these points. It can also be used on a collection of points of different dimensions. This implementation however covers points on a plane. It essentially calculates the lines between points which together contain all points. In comparing different solutions to this problem we can describe each algorithm in terms of it's big-O time complexity.
4
4
5
-
Given a group of points on a plane. The Convex Hull algorithm calculates the shape (made up from the points itself) containing all these points. It can also be used on a collection of points of different dimensions. This implementation however covers points on a plane. It essentially calculates the lines between points which together contain all points.
5
+
There are multiple Convex Hull algorithms but this solution is called Quickhull, is comes from the work of both W. Eddy in 1977 and also separately A. Bykat in 1978, this algorithm has an expected time complexity of O(n log n), but it's worst-case time-complexity can be O(n^2) . With average conditions the algorithm has ok efficiency, but it's time-complexity can start to head become more exponential in cases of high symmetry or where there are points lying on the circumference of a circle for example.
6
6
7
7
## Quickhull
8
8
9
9
The quickhull algorithm works as follows:
10
-
The algorithm takes an input of a collection of points. These points should be ordered on their x-coordinate value. We pick the two points A and B with the smallest(A) and the largest(B) x-coordinate. These of course have to be part of the hull. Imagine a line from point A to point B. All points to the right of this line are grouped in an array S1. Imagine now a line from point B to point A. (this is of course the same line as before just with opposite direction) Again all points to the right of this line are grouped in an array, S2 this time.
11
-
We now define the following recursive function:
10
+
11
+
- The algorithm takes an input of a collection of points. These points should be ordered on their x-coordinate value.
12
+
- We first find the two points A and B with the minimum(A) and the maximum(B) x-coordinates (as these will obviously be part of the hull).
13
+
- Use the line formed by the two points to divide the set in two subsets of points, which will be processed recursively.
14
+
- Determine the point, on one side of the line, with the maximum distance from the line. The two points found before along with this one form a triangle.
15
+
- The points lying inside of that triangle cannot be part of the convex hull and can therefore be ignored in the next steps.
16
+
- Repeat the previous two steps on the two lines formed by the triangle (not the initial line).
17
+
- Keep on doing so on until no more points are left, the recursion has come to an end and the points selected constitute the convex hull.
18
+
19
+
20
+
Our functioni will have the following defininition:
0 commit comments