shape_convex/convex2d/
mod.rs1use shape_core::{Point, PointSet, Polygon, Real};
2use std::cmp::Ordering::Equal;
3use std::collections::BTreeSet;
4use std::fmt::Debug;
5use std::ops::AddAssign;
6
7#[derive(Debug)]
13pub struct FastConvexHull<T> {
14 bounds: Vec<Point<T>>,
15 inners: Vec<Point<T>>,
16}
17
18
19#[derive(Debug)]
21pub struct ConvexHull<T> {
22 bounds: BTreeSet<Point<T>>,
23 inners: BTreeSet<Point<T>>,
24}
25
26mod solver;
27
28impl<T> FastConvexHull<T> {
29 pub fn clear(&mut self) {
31 self.inners.clear();
32 }
33 pub fn bound_points(&self) -> impl Iterator<Item=Point<&T>> {
34 self.bounds.iter().map(|v| v.ref_inner())
35 }
36 pub fn inner_points(&self) -> impl Iterator<Item=Point<&T>> {
37 self.inners.iter().map(|v| v.ref_inner())
38 }
39 pub fn as_polygon(&self) -> Polygon<T> where T: Clone {
40 Polygon {
41 points_set: PointSet { points: self.bounds.clone() },
42 }
43 }
44}