pub struct SPolygon {
pub vertices: Vec<Point>,
pub bbox: Rect,
pub area: f32,
pub diameter: f32,
pub poi: Circle,
pub surrogate: Option<SPSurrogate>,
}
Expand description
A Simple Polygon is a polygon that does not intersect itself and contains no holes. It is a closed shape with a finite number of vertices and edges. read more
Fields§
§vertices: Vec<Point>
Set of points that form the polygon
bbox: Rect
Bounding box
area: f32
Area of its interior
diameter: f32
Maximum distance between any two points in the polygon
poi: Circle
Pole of inaccessibility represented as a circle
surrogate: Option<SPSurrogate>
Optional surrogate representation of the polygon (subset of the original)
Implementations§
Source§impl SPolygon
impl SPolygon
Sourcepub fn new(points: Vec<Point>) -> Result<Self>
pub fn new(points: Vec<Point>) -> Result<Self>
Create a new simple polygon from a set of points, expensive operations are performed here! Use Self::clone() or Self::transform() to avoid recomputation.
pub fn generate_surrogate(&mut self, config: SPSurrogateConfig)
pub fn vertex(&self, i: usize) -> Point
pub fn edge(&self, i: usize) -> Edge
pub fn edge_iter(&self) -> impl Iterator<Item = Edge> + '_
pub fn n_vertices(&self) -> usize
pub fn surrogate(&self) -> &SPSurrogate
pub fn calculate_diameter(points: Vec<Point>) -> f32
pub fn generate_bounding_box(points: &[Point]) -> Rect
pub fn calculate_area(points: &[Point]) -> f32
pub fn calculate_poi(points: &[Point], diameter: f32) -> Circle
pub fn centroid(&self) -> Point
Trait Implementations§
Source§impl CollidesWith<Point> for SPolygon
impl CollidesWith<Point> for SPolygon
fn collides_with(&self, point: &Point) -> bool
Source§impl DistanceTo<Point> for SPolygon
impl DistanceTo<Point> for SPolygon
Source§fn distance_to(&self, point: &Point) -> f32
fn distance_to(&self, point: &Point) -> f32
Minimum distance between two primitives. Will be 0 in case of a collision.
Source§fn sq_distance_to(&self, point: &Point) -> f32
fn sq_distance_to(&self, point: &Point) -> f32
Squared version of DistanceTo::distance_to
Source§impl SeparationDistance<Point> for SPolygon
impl SeparationDistance<Point> for SPolygon
Source§fn separation_distance(&self, point: &Point) -> (GeoPosition, f32)
fn separation_distance(&self, point: &Point) -> (GeoPosition, f32)
In case of a collision between
self
and other
, returns GeoPosition::Interior and the minimum distance to separate the two primitives.
Otherwise, returns GeoPosition::Exterior and the minimum distance between the two primitives. (similar to DistanceTo::distance_to)Source§fn sq_separation_distance(&self, point: &Point) -> (GeoPosition, f32)
fn sq_separation_distance(&self, point: &Point) -> (GeoPosition, f32)
Squared version of SeparationDistance::separation_distance
Source§impl Transformable for SPolygon
impl Transformable for SPolygon
Source§fn transform(&mut self, t: &Transformation) -> &mut Self
fn transform(&mut self, t: &Transformation) -> &mut Self
Applies a transformation to
self
.Source§fn transform_clone(&self, t: &Transformation) -> Self
fn transform_clone(&self, t: &Transformation) -> Self
Applies a transformation to a clone.
Source§impl TransformableFrom for SPolygon
impl TransformableFrom for SPolygon
Source§fn transform_from(&mut self, reference: &Self, t: &Transformation) -> &mut Self
fn transform_from(&mut self, reference: &Self, t: &Transformation) -> &mut Self
Applies a transformation on the reference object and stores the result in
self
.Auto Trait Implementations§
impl Freeze for SPolygon
impl RefUnwindSafe for SPolygon
impl Send for SPolygon
impl Sync for SPolygon
impl Unpin for SPolygon
impl UnwindSafe for SPolygon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more