A Direct Convex Hull Algorithm
John Henckel
Rural Route 1
Zumbro Falls, MN 55991
Tel. 507-253-1203
henckel@iname.com,
http://www.formulus.com
(C) 1998, John Henckel
ABSTRACT
The convex hull problem is to find the smallest
convex polyhedron that contains a given finite set of points.
This paper describes a practical convex hull algorithm for 3-dimensional points.
The algorithm uses a gift-wrapping approach and it is easy to implement.
An implementation in C++ is used in the
Tru-Physics simulation program
for Microsoft Windows.
Introduction
The convex hull of a set of points is the smallest convex polyhedron that contains
the points.
We describe the convex hull as a list of faces and edges. Each face has a list of
perimeter points in clockwise order. Each edge has two points.
The two approaches to the convex hull problem are incremental and gift-wrapping.
The incremental approach, such as QuickHull [Barber et al. 96], starts with a
convex hull (for example, 4 non-coplanar points) and repeatedly adds a
point to the convex hull of the previously processed points.
The gift-wrapping approach, such as the Preparata and Hong algorithm
[Edelsbrunner 87], starts with a single
face and repeatedly adds a face to the edge of a previous face.
The algorithm described here is a variation of the gift-wrapping approach,
though much simpler than the Preparata and Hong algorithm.
Informal Algorithm Description
We first find two points such that the line segment connecting them is
an edge on the convex hull.
This edge is the seed of the iterative part of the algorithm
and we put the edge in the to-do list.
At each iteration, we take a known edge, (A, B), from
the to-do list and find a face adjacent to this edge.
To find a face, we begin by choosing any non-collinear point, C.
If other points are above the plane ABC, choose a new point, C', to be the
point farthest above ABC and repeat using the new point, C'.
If all other points are
below or on the plane ABC, we build a new face with
point A, B, C, any other coplanar points. Also we compute the edges of
the face and add them to the to-do list.
When the to-do list is empty, we are done.
Definitions
- Vector or Point
- refer to a data structure
containing three floating point numbers, x, y, and z.
- Data Points
- the set of points that are the input to the algorithm.
- Plane
- is a 2D flat surface described by a point on the
plane, and the normal direction vector which is perpendicular to the plane.
- Face Plane
- a plane containing one of the convex hull faces.
No data points are above a face plane (in the direction
of the normal vector).
- Edge
- is a line segment connecting two data points at the intersection
of two face planes.
Algorithm
- Get input, N = number of points
- If N < 3, return error
- Initialize: FaceList = empty, EdgeList = empty, ToDoList = empty.
- Find two points, A and B, that form an edge (see details below).
- Choose any point C, not collinear with A and B.
- Compute cross product NM = (A - B) x (C - B).
M = the plane at B with normal NM.
- For every data point (except A, B, C) compute signed distance to plane
dist(P, M) = (P - B) * NM
and find the point, P, with maximum distance
- If dist(P, M) > 0, then C = P and go to 6.
Else we know M is a face plane.
- Create a face, F, with all data points on the plane M. (This will
include A, B, C and possibly others).
- Sort F points according to angle(P) = (P - B) * (A - B)
- Add F to FaceList.
- For each edge, E = (P1, P2), clockwise on the perimeter of F do {
ER = (P2, P1).
If ER is in the EdgeList list {
If E is in the ToDoList, remove E from the ToDoList.
}
Else {
Add E to the EdgeList
Add ER to the ToDoList
}
}
- If the ToDoList is empty, return the EdgeList and FaceList.
- Else get (A, B) the next edge in the ToDoList and go to 5.
Finding the initial edge
Find the initial edge to seed the interative part of the algorithm as follows.
- Choose a random unit vector, D.
- Find the extreme point, A, in direction D. Simply find the maximum of the dot product A*D.
- If more than three points have the maximum distance, go to 1.
- M = the plane perpendicular to D through point A.
Choose the point, B, with the smallest angle at A to the plane M.
The sine of the angle is computed, sineOfAngle(B) = ( (B - A) / ||B - A|| ) * D.
- If more than one point has the minimum angle value, choose the point, B, nearest to A.
- E = (A, B) is an edge of the convex hull.
Bibliography
-
[Barber, et al. 96] C. Bradford Barber, David P. Dobkin, Hannu Huhdanpaa, "The Quickhull Algorithm
for Convex Hulls", ACM Trans. on Mathematical Software, V. 22, No. 4 (Dec 1996), pp. 469-483.
-
[Edelsbrunner 87] H. Edelsbrunner, "Algorithms in Combinatorial Geometry", "EATCS Monographs on
Theoretical Computer Science", v. 10, Springer-Verlag, Heidelberg, West Germany, 1987.