Struct fenris_geometry::ConvexPolygon
source · pub struct ConvexPolygon<T>where
T: Scalar,{ /* private fields */ }
Implementations§
source§impl<T> ConvexPolygon<T>where
T: Scalar,
impl<T> ConvexPolygon<T>where
T: Scalar,
sourcepub fn from_vertices(vertices: Vec<Point2<T>>) -> ConvexPolygon<T>
pub fn from_vertices(vertices: Vec<Point2<T>>) -> ConvexPolygon<T>
Construct a new convex polygon from the given vertices, assumed to be ordered in a counter-clockwise way such that (i, i + 1) forms an edge between vertex i and i + 1.
It is assumed that the polygon is convex.
pub fn vertices(&self) -> &[Point2<T>]
sourcepub fn num_edges(&self) -> usize
pub fn num_edges(&self) -> usize
Returns the number of edges in the polygon. Note that a single point has 1 edge, pointing from itself to itself, a line segment has two edges, and in general the number of edges is equal to the number of vertices.
pub fn edges(&self) -> impl Iterator<Item = (&Point2<T>, &Point2<T>)>
pub fn is_empty(&self) -> bool
pub fn is_point(&self) -> bool
pub fn is_line_segment(&self) -> bool
source§impl<T> ConvexPolygon<T>where
T: Real,
impl<T> ConvexPolygon<T>where
T: Real,
sourcepub fn half_planes<'a>(&'a self) -> impl Iterator<Item = HalfPlane<T>> + 'a
pub fn half_planes<'a>(&'a self) -> impl Iterator<Item = HalfPlane<T>> + 'a
Iterates over the half planes that define the polygon.
Every non-degenerate polygon can be represented by the intersection of a finite number of closed half-planes.
If the polygon is degenerate, the intersection of the half planes returned by this method will in general not be sufficient to describe the polygon.
sourcepub fn contains_point(&self, point: &Point2<T>) -> bool
pub fn contains_point(&self, point: &Point2<T>) -> bool
Determines if the (closed) convex polygon contains the given point.
sourcepub fn intersect_halfplane(&self, half_plane: &HalfPlane<T>) -> ConvexPolygon<T>
pub fn intersect_halfplane(&self, half_plane: &HalfPlane<T>) -> ConvexPolygon<T>
Computes the intersection with the current polygon and the given half plane, and returns a new polygon that holds the result.
Note: No steps have been made to make this routine numerically robust. TODO: Make numerically robust?
sourcepub fn intersect_polygon(&self, other: &ConvexPolygon<T>) -> Self
pub fn intersect_polygon(&self, other: &ConvexPolygon<T>) -> Self
Computes the intersection of this polygon and the given convex polygon.
sourcepub fn triangulate<'a>(&'a self) -> impl Iterator<Item = Triangle2d<T>> + 'a
pub fn triangulate<'a>(&'a self) -> impl Iterator<Item = Triangle2d<T>> + 'a
Splits the convex polygon into a set of disjoint triangles that exactly cover the area of the polygon.
pub fn triangulate_into_vec(&self) -> Vec<Triangle2d<T>>
Trait Implementations§
source§impl<T> Clone for ConvexPolygon<T>where
T: Scalar + Clone,
impl<T> Clone for ConvexPolygon<T>where
T: Scalar + Clone,
source§fn clone(&self) -> ConvexPolygon<T>
fn clone(&self) -> ConvexPolygon<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> From<ConvexPolygon<T>> for SimplePolygon2d<T>where
T: Scalar,
impl<T> From<ConvexPolygon<T>> for SimplePolygon2d<T>where
T: Scalar,
source§fn from(poly: ConvexPolygon<T>) -> Self
fn from(poly: ConvexPolygon<T>) -> Self
source§impl<T> From<LineSegment<T, Const<2>>> for ConvexPolygon<T>where
T: Scalar,
impl<T> From<LineSegment<T, Const<2>>> for ConvexPolygon<T>where
T: Scalar,
source§fn from(segment: LineSegment2d<T>) -> Self
fn from(segment: LineSegment2d<T>) -> Self
source§impl<T> From<Triangle<T, Const<2>>> for ConvexPolygon<T>where
T: Scalar,
impl<T> From<Triangle<T, Const<2>>> for ConvexPolygon<T>where
T: Scalar,
source§fn from(triangle: Triangle2d<T>) -> Self
fn from(triangle: Triangle2d<T>) -> Self
source§impl<T> PartialEq<ConvexPolygon<T>> for ConvexPolygon<T>where
T: Scalar + PartialEq,
impl<T> PartialEq<ConvexPolygon<T>> for ConvexPolygon<T>where
T: Scalar + PartialEq,
source§fn eq(&self, other: &ConvexPolygon<T>) -> bool
fn eq(&self, other: &ConvexPolygon<T>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<T> Eq for ConvexPolygon<T>where
T: Scalar + Eq,
impl<T> StructuralEq for ConvexPolygon<T>where
T: Scalar,
impl<T> StructuralPartialEq for ConvexPolygon<T>where
T: Scalar,
Auto Trait Implementations§
impl<T> RefUnwindSafe for ConvexPolygon<T>where
T: RefUnwindSafe,
impl<T> Send for ConvexPolygon<T>where
T: Send,
impl<T> Sync for ConvexPolygon<T>where
T: Sync,
impl<T> Unpin for ConvexPolygon<T>where
T: Unpin,
impl<T> UnwindSafe for ConvexPolygon<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.