pub struct SimplePolygon {
pub points: Vec<Point>,
pub bbox: AARectangle,
pub area: fsize,
pub diameter: fsize,
pub poi: Circle,
pub surrogate: Option<SPSurrogate>,
}
Expand description
Geometric primitive representing a simple polygon: https://en.wikipedia.org/wiki/Simple_polygon
Fields§
§points: Vec<Point>
Set of bounds describing the polygon
bbox: AARectangle
Bounding box
area: fsize
§diameter: fsize
Maximum distance between any two points in the polygon
poi: Circle
Pole of inaccessibility
surrogate: Option<SPSurrogate>
Surrogate representation (subset of the simple polygon)
Implementations§
Source§impl SimplePolygon
impl SimplePolygon
Sourcepub fn new(points: Vec<Point>) -> Self
pub fn new(points: Vec<Point>) -> 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 get_point(&self, i: usize) -> Point
pub fn get_edge(&self, i: usize) -> Edge
pub fn edge_iter(&self) -> impl Iterator<Item = Edge> + '_
pub fn number_of_points(&self) -> usize
pub fn surrogate(&self) -> &SPSurrogate
pub fn calculate_diameter(points: Vec<Point>) -> fsize
pub fn generate_bounding_box(points: &[Point]) -> AARectangle
pub fn calculate_area(points: &[Point]) -> fsize
pub fn calculate_poi(points: &[Point], diameter: fsize) -> Circle
pub fn center_around_centroid(self) -> (SimplePolygon, Transformation)
Trait Implementations§
Source§impl Clone for SimplePolygon
impl Clone for SimplePolygon
Source§fn clone(&self) -> SimplePolygon
fn clone(&self) -> SimplePolygon
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl CollidesWith<Point> for SimplePolygon
impl CollidesWith<Point> for SimplePolygon
fn collides_with(&self, point: &Point) -> bool
Source§impl Debug for SimplePolygon
impl Debug for SimplePolygon
Source§impl Distance<Point> for SimplePolygon
impl Distance<Point> for SimplePolygon
Source§impl<T> From<T> for SimplePolygonwhere
T: Borrow<AARectangle>,
impl<T> From<T> for SimplePolygonwhere
T: Borrow<AARectangle>,
Source§impl SeparationDistance<Point> for SimplePolygon
impl SeparationDistance<Point> for SimplePolygon
Source§fn separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
fn separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
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 Distance::distance)Source§fn sq_separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
fn sq_separation_distance(&self, point: &Point) -> (GeoPosition, fsize)
Squared version of SeparationDistance::separation_distance
Source§impl Shape for SimplePolygon
impl Shape for SimplePolygon
Source§impl Transformable for SimplePolygon
impl Transformable for SimplePolygon
fn transform(&mut self, t: &Transformation) -> &mut Self
fn transform_clone(&self, t: &Transformation) -> Self
Source§impl TransformableFrom for SimplePolygon
impl TransformableFrom for SimplePolygon
fn transform_from(&mut self, reference: &Self, t: &Transformation) -> &mut Self
Auto Trait Implementations§
impl Freeze for SimplePolygon
impl RefUnwindSafe for SimplePolygon
impl Send for SimplePolygon
impl Sync for SimplePolygon
impl Unpin for SimplePolygon
impl UnwindSafe for SimplePolygon
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