pub struct Polygon { /* private fields */ }Expand description
A convex polygon in 3D space, defined by an ordered list of vertices.
Vertices should be coplanar and in counter-clockwise winding order when viewed from the front (the direction the normal points).
Implementations§
Source§impl Polygon
impl Polygon
Sourcepub fn new(vertices: Vec<Point3<f32>>) -> Self
pub fn new(vertices: Vec<Point3<f32>>) -> Self
Creates a new polygon from a list of vertices.
§Panics (debug builds only)
- Panics if fewer than 3 vertices are provided.
- Panics if vertices are not coplanar.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the polygon has no vertices (always false for valid polygons).
Sourcepub fn normal(&self) -> Vector3<f32>
pub fn normal(&self) -> Vector3<f32>
Computes the (unnormalized) normal vector of the polygon.
Uses the first three vertices to compute the normal via cross product. The direction follows the right-hand rule based on vertex winding.
Sourcepub fn unit_normal(&self) -> Option<Vector3<f32>>
pub fn unit_normal(&self) -> Option<Vector3<f32>>
Computes the unit normal vector of the polygon.
Returns None if the first three vertices are collinear.
Sourcepub fn plane(&self) -> Plane3D
pub fn plane(&self) -> Plane3D
Returns the plane that this polygon lies on.
§Panics
Panics if the first three vertices are collinear.
Sourcepub fn classify(&self, plane: &Plane3D) -> Classification
pub fn classify(&self, plane: &Plane3D) -> Classification
Classifies this polygon relative to a plane.
Returns:
Frontif all vertices are in front of the planeBackif all vertices are behind the planeCoplanarif all vertices lie on the planeSpanningif vertices are on both sides
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§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.