pub struct Polygon2 {
pub vertices: Vec<DVec2>,
}Expand description
A simple polygon in the XY-plane, without holes.
The closing edge is implicit, so the last vertex joins the first. Repeating the first vertex at the end creates a zero-length edge rather than closing the ring, which is a common source of degenerate imported data.
Simplicity – no self-intersection – is assumed and not checked: that is a tolerance-dependent judgement, and the types here hold data rather than enforce policy. A polygon set with holes is a different concept; see the planar overlay crate’s region type for that.
Fields§
§vertices: Vec<DVec2>Boundary vertices in order. The closing edge is implicit.
Implementations§
Source§impl Polygon2
impl Polygon2
Sourcepub fn signed_area2(&self) -> f64
pub fn signed_area2(&self) -> f64
Twice the signed area by the shoelace formula.
Summed about the first vertex rather than the origin. The two agree mathematically, but a polygon in georeferenced coordinates sits far from the origin, where the terms are large and nearly cancel; rebasing keeps the terms the size of the polygon instead of the size of the coordinate system.
Fewer than three vertices enclose nothing and give zero.
Sourcepub fn signed_area(&self) -> f64
pub fn signed_area(&self) -> f64
Signed area: positive counter-clockwise, negative clockwise.
Sourcepub fn is_counter_clockwise(&self) -> bool
pub fn is_counter_clockwise(&self) -> bool
Whether the vertex order is counter-clockwise.
A degenerate polygon has no winding; this reports false for it rather
than inventing one.
Trait Implementations§
Source§impl From<Polygon2> for Ring
A Ring is a closed boundary and so is Polygon2; converting between
them moves the points and nothing else.
impl From<Polygon2> for Ring
A Ring is a closed boundary and so is Polygon2; converting between
them moves the points and nothing else.
The two exist separately because they are reached from different places:
Polygon2 is a foundation value type usable without this crate, while
Ring is what the overlay consumes. Making them the same type
would drag the planar boolean vocabulary into axiolid-core.
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 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> 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 more