convex_hull_graham

Function convex_hull_graham 

Source
pub fn convex_hull_graham<T: Float + Debug>(
    points: &ArrayView2<'_, T>,
) -> Array2<T>
Expand description

Compute the convex hull of a polygon using the Graham scan algorithm.

§Arguments

  • points - The input points

§Returns

  • A new array containing the convex hull vertices

§Examples

use ndarray::array;
use scirs2_spatial::polygon::convex_hull_graham;

// A set of points
let points = array![
    [0.0, 0.0],
    [1.0, 0.0],
    [0.5, 0.5],  // Inside point
    [1.0, 1.0],
    [0.0, 1.0],
];

let hull = convex_hull_graham(&points.view());

// The hull should have only 4 points (the corners)
assert_eq!(hull.shape()[0], 4);