pub struct Polygon2 {
pub vertices: VecDeque<Vec2>,
}Fields§
§vertices: VecDeque<Vec2>Implementations§
Source§impl Polygon2
impl Polygon2
Sourcepub fn terminal(&self, terminal: PolygonTerminal) -> Option<Vec2>
pub fn terminal(&self, terminal: PolygonTerminal) -> Option<Vec2>
Returns the terminal vertex of the polygon, or None if the polygon is empty.
Sourcepub fn extend_by_line(
&mut self,
terminal: PolygonTerminal,
other_line_end: Vec2,
)
pub fn extend_by_line( &mut self, terminal: PolygonTerminal, other_line_end: Vec2, )
Extends the polygon by a line from the terminal vertex to other_line_end.
Sourcepub fn merge_polygon(
&mut self,
my_terminal: PolygonTerminal,
other: Polygon2,
other_terminal: PolygonTerminal,
)
pub fn merge_polygon( &mut self, my_terminal: PolygonTerminal, other: Polygon2, other_terminal: PolygonTerminal, )
This assumes that the polygon to be merged doesn’t contain any vertices that are already part of this polygon.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns true if the polygon is closed (the terminal vertex is the same as the first vertex).
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Closes the polygon by adding the terminal vertex to the front if it is not already closed.
Sourcepub fn length(&self) -> f32
pub fn length(&self) -> f32
Returns the length (cumulative distance between vertices) of the polygon.
Sourcepub fn min_max(&self) -> (Vec2, Vec2)
pub fn min_max(&self) -> (Vec2, Vec2)
Returns the minimum and maximum coordinates of the polygon.
The minimum is the smallest x and y values, and the maximum is the largest x and y values.
The pair forms an AABB (axis-aligned bounding box) that encloses the polygon.
Sourcepub fn contains_point(&self, point: Vec2) -> bool
pub fn contains_point(&self, point: Vec2) -> bool
Wether a point is inside the polygon.
Assumes that the polygon is closed.
Trait Implementations§
impl StructuralPartialEq for Polygon2
Auto Trait Implementations§
impl Freeze for Polygon2
impl RefUnwindSafe for Polygon2
impl Send for Polygon2
impl Sync for Polygon2
impl Unpin for Polygon2
impl UnsafeUnpin for Polygon2
impl UnwindSafe for Polygon2
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.