pub fn graham_scan<O, T>(
points: &[Point2<T>],
assume_sorted: bool,
voxel_size: Option<O>,
) -> Option<Vec<Point2<T>>>where
O: AsPrimitive<isize> + ComplexField + Copy + PartialOrd,
T: AsPrimitive<O> + Debug + IsNan + NumAssign + PartialOrd,
usize: AsPrimitive<T>,
Expand description
Computes the convex hull of a set of points using the Graham Scan algorithm. Specifically the Monotone Chain variant This version sorts the points lexicographically before computing the convex hull. A downside of using this algorithm is that it does not handle collinear points well.
§Arguments
points
- A slice of points to compute the convex hull ofassume_sorted
- A boolean indicating whether the points are already sorted lexicographically, this is critical for correctness so make sure you don’t set this totrue
unless you are sure the points are sortedvoxel_size
- An optional parameter specifying the voxel size by which to downsample the point cloud before computing the convex hull, useful in reducing errors due to close or identical vertices.
§Genericsoc -
O
- The output type of the trigonometric functions, essentially the precision of the calculationsT
- The type of the points, can be of any scalar type
§Returns
An Option
of Vec<Point2<T>>
representing the convex hull, or None
if there were not enough points to compute a convex hull, or if all points are collinear