Language Reference |
finds a convex hull of a set of planar points
where matrix is an matrix of points.
The argument for the CVEXHULL function is an matrix of points. The result matrix is an matrix of indices. The indices of points in the convex hull in counterclockwise order are returned as the first part of the result matrix, and the negative of the indices of the internal points are returned as the remaining elements of the result matrix. Any points that lie on the convex hull but lie on a line segment joining two other points on the convex hull are not included as part of the convex hull.
The result matrix can be split into positive and negative parts by using the LOC function. For example, the following statements find the index vector for the convex hull and print the associated points:
points = { 0 2, 0.5 2, 1 2, 0.5 1, 0 0, 0.5 0, 1 0, 2 -1, 2 0, 2 1, 3 0, 4 1, 4 0, 4 -1, 5 2, 5 1, 5 0, 6 0 }; indices = cvexhull( points ); hullIndices = indices[loc(indices>0)]; convexHull = points[hullIndices, ]; print convexHull; CONVEXHULL 0 2 0 0 2 -1 4 -1 6 0 5 2
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.