Trait geo::algorithm::convex_hull::ConvexHull[][src]

pub trait ConvexHull {
    type Scalar: GeoNum;
    fn convex_hull(&self) -> Polygon<Self::Scalar>;
}

Returns the convex hull of a Polygon. The hull is always oriented counter-clockwise.

This implementation uses the QuickHull algorithm, based on Barber, C. Bradford; Dobkin, David P.; Huhdanpaa, Hannu (1 December 1996) Original paper here: http://www.cs.princeton.edu/~dpd/Papers/BarberDobkinHuhdanpaa.pdf

Examples

use geo::{line_string, polygon};
use geo::algorithm::convex_hull::ConvexHull;

// an L shape
let poly = polygon![
    (x: 0.0, y: 0.0),
    (x: 4.0, y: 0.0),
    (x: 4.0, y: 1.0),
    (x: 1.0, y: 1.0),
    (x: 1.0, y: 4.0),
    (x: 0.0, y: 4.0),
    (x: 0.0, y: 0.0),
];

// The correct convex hull coordinates
let correct_hull = line_string![
    (x: 4.0, y: 0.0),
    (x: 4.0, y: 1.0),
    (x: 1.0, y: 4.0),
    (x: 0.0, y: 4.0),
    (x: 0.0, y: 0.0),
    (x: 4.0, y: 0.0),
];

let res = poly.convex_hull();
assert_eq!(res.exterior(), &correct_hull);

Associated Types

Loading content...

Required methods

fn convex_hull(&self) -> Polygon<Self::Scalar>[src]

Loading content...

Implementors

impl<T> ConvexHull for LineString<T> where
    T: GeoNum
[src]

type Scalar = T

impl<T> ConvexHull for MultiLineString<T> where
    T: GeoNum
[src]

type Scalar = T

impl<T> ConvexHull for MultiPoint<T> where
    T: GeoNum
[src]

type Scalar = T

impl<T> ConvexHull for MultiPolygon<T> where
    T: GeoNum
[src]

type Scalar = T

impl<T> ConvexHull for Polygon<T> where
    T: GeoNum
[src]

type Scalar = T

Loading content...