| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/Gift_wrapping_algorithm |
In computational geometry, the gift wrapping algorithm is an algorithm for computing the convex hull of a given set of points.
. Also, the complete implementation must choose how to deal with degenerate cases when the convex hull has only 1 or 2 vertices, as well as with the issues of limited arithmetic precision, both of computer computations and input data.The gift wrapping algorithm begins with i=0 and a point p0 known to be on the convex hull, e.g., the leftmost point, and selects the point pi+1 such that all points are to the right of the line pi pi+1. This point may be found in O(n) time by comparing polar angles of all points with respect to point pi taken for the center of polar coordinates. Letting i=i+1, and repeating with until one reaches ph=p0 again yields the convex hull in h steps. In two dimensions, the gift wrapping algorithm is similar to the process of winding a string (or wrapping paper) around the set of points.
The approach can be extended to higher dimensions.
The inner loop checks every point in the set S, and the outer loop repeats for each point on the hull. Hence the total run time is
| View original on Wikipedia | Back | FazBrowse Home |