pub struct Polygon {
pub points: Vec<Point>,
}Expand description
A closed polygon: a flat list of points plus an explicit count.
The flat representation keeps the hot triangulation loop free of
indirection: the inner scan reads points[i] directly instead of
chasing a per-vertex pointer.
Fields§
§points: Vec<Point>The vertices, in order.
Implementations§
Source§impl Polygon
Inherent implementation of Polygon.
impl Polygon
Inherent implementation of Polygon.
Sourcepub fn from_coordinates(coordinates: &[f32]) -> Self
pub fn from_coordinates(coordinates: &[f32]) -> Self
Sourcepub fn signed_area(&self) -> f64
pub fn signed_area(&self) -> f64
Returns the polygon’s area, using the shoelace formula.
The sign of the result encodes the winding direction: a positive area means the vertices run clockwise in a y-down coordinate system.
§Returns
f64- A 64-bit float.
Sourcepub fn is_clockwise(&self) -> bool
pub fn is_clockwise(&self) -> bool
Source§impl Polygon
impl Polygon
pub fn get_points(&self) -> &Vec<Point>
pub fn get_mut_points(&mut self) -> &mut Vec<Point>
pub fn set_points(&mut self, val: Vec<Point>) -> &mut Self
Trait Implementations§
impl StructuralPartialEq for Polygon
Auto Trait Implementations§
impl Freeze for Polygon
impl RefUnwindSafe for Polygon
impl Send for Polygon
impl Sync for Polygon
impl Unpin for Polygon
impl UnsafeUnpin for Polygon
impl UnwindSafe for Polygon
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