Struct SPolygon

Source
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

Source

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.

Source

pub fn generate_surrogate(&mut self, config: SPSurrogateConfig)

Source

pub fn vertex(&self, i: usize) -> Point

Source

pub fn edge(&self, i: usize) -> Edge

Source

pub fn edge_iter(&self) -> impl Iterator<Item = Edge> + '_

Source

pub fn n_vertices(&self) -> usize

Source

pub fn surrogate(&self) -> &SPSurrogate

Source

pub fn calculate_diameter(points: Vec<Point>) -> f32

Source

pub fn generate_bounding_box(points: &[Point]) -> Rect

Source

pub fn calculate_area(points: &[Point]) -> f32

Source

pub fn calculate_poi(points: &[Point], diameter: f32) -> Circle

Source

pub fn centroid(&self) -> Point

Trait Implementations§

Source§

impl Clone for SPolygon

Source§

fn clone(&self) -> SPolygon

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CollidesWith<Point> for SPolygon

Source§

fn collides_with(&self, point: &Point) -> bool

Source§

impl Debug for SPolygon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DistanceTo<Point> for SPolygon

Source§

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

Squared version of DistanceTo::distance_to
Source§

impl<T> From<T> for SPolygon
where T: Borrow<Rect>,

Source§

fn from(r: T) -> Self

Converts to this type from the input type.
Source§

impl SeparationDistance<Point> for SPolygon

Source§

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)

Source§

impl Transformable for SPolygon

Source§

fn transform(&mut self, t: &Transformation) -> &mut Self

Applies a transformation to self.
Source§

fn transform_clone(&self, t: &Transformation) -> Self

Applies a transformation to a clone.
Source§

impl TransformableFrom for SPolygon

Source§

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V