Struct plane_split::Polygon
source · pub struct Polygon<A> {
pub points: [Point3D<f64>; 4],
pub plane: Plane,
pub anchor: A,
}
Expand description
A convex polygon with 4 points lying on a plane.
Fields§
§points: [Point3D<f64>; 4]
Points making the polygon.
plane: Plane
A plane describing polygon orientation.
anchor: A
A simple anchoring index to allow association of the produced split polygons with the original one.
Implementations§
source§impl<A> Polygon<A>where
A: Copy,
impl<A> Polygon<A>where
A: Copy,
sourcepub fn from_points(points: [Point3D<f64>; 4], anchor: A) -> Option<Self>
pub fn from_points(points: [Point3D<f64>; 4], anchor: A) -> Option<Self>
Construct a polygon from points that are already transformed. Return None if the polygon doesn’t contain any space.
sourcepub fn from_rect(rect: Rect<f64>, anchor: A) -> Self
pub fn from_rect(rect: Rect<f64>, anchor: A) -> Self
Construct a polygon from a non-transformed rectangle.
sourcepub fn from_transformed_rect(
rect: Rect<f64>,
transform: Transform3D<f64>,
anchor: A,
) -> Option<Self>
pub fn from_transformed_rect( rect: Rect<f64>, transform: Transform3D<f64>, anchor: A, ) -> Option<Self>
Construct a polygon from a rectangle with 3D transform.
sourcepub fn from_transformed_rect_with_inverse(
rect: Rect<f64>,
transform: &Transform3D<f64>,
inv_transform: &Transform3D<f64>,
anchor: A,
) -> Option<Self>
pub fn from_transformed_rect_with_inverse( rect: Rect<f64>, transform: &Transform3D<f64>, inv_transform: &Transform3D<f64>, anchor: A, ) -> Option<Self>
Construct a polygon from a rectangle with an invertible 3D transform.
sourcepub fn untransform_point(&self, point: Point3D<f64>) -> Point2D<f64>
pub fn untransform_point(&self, point: Point3D<f64>) -> Point2D<f64>
Bring a point into the local coordinate space, returning the 2D normalized coordinates.
sourcepub fn transform(&self, transform: &Transform3D<f64>) -> Option<Polygon<A>>
pub fn transform(&self, transform: &Transform3D<f64>) -> Option<Polygon<A>>
Transform a polygon by an affine transform (preserving straight lines).
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if all the points are indeed placed on the plane defined by the normal and offset, and the winding order is consistent.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if the polygon doesn’t contain any space. This may happen after a sequence of splits, and such polygons should be discarded.
sourcepub fn project_on(&self, vector: &Vector3D<f64>) -> LineProjection
pub fn project_on(&self, vector: &Vector3D<f64>) -> LineProjection
Project this polygon onto a 3D vector, returning a line projection. Note: we can think of it as a projection to a ray placed at the origin.
sourcepub fn intersect_plane(&self, other: &Plane) -> Intersection<Line>
pub fn intersect_plane(&self, other: &Plane) -> Intersection<Line>
Compute the line of intersection with an infinite plane.
sourcepub fn intersect(&self, other: &Self) -> Intersection<Line>
pub fn intersect(&self, other: &Self) -> Intersection<Line>
Compute the line of intersection with another polygon.
fn split_impl( &mut self, first: (usize, Point3D<f64>), second: (usize, Point3D<f64>), ) -> (Option<Self>, Option<Self>)
sourcepub fn split(&mut self, line: &Line) -> (Option<Self>, Option<Self>)
👎Deprecated: Use split_with_normal instead
pub fn split(&mut self, line: &Line) -> (Option<Self>, Option<Self>)
Split the polygon along the specified Line
.
Will do nothing if the line doesn’t belong to the polygon plane.
sourcepub fn split_with_normal(
&mut self,
line: &Line,
normal: &Vector3D<f64>,
) -> (Option<Self>, Option<Self>)
pub fn split_with_normal( &mut self, line: &Line, normal: &Vector3D<f64>, ) -> (Option<Self>, Option<Self>)
Split the polygon along the specified Line
, with a normal to the split line provided.
This is useful when called by the plane splitter, since the other plane’s normal
forms the side direction here, and figuring out the actual line of split isn’t needed.
Will do nothing if the line doesn’t belong to the polygon plane.
sourcepub fn cut(
&self,
poly: &Self,
front: &mut SmallVec<[Polygon<A>; 2]>,
back: &mut SmallVec<[Polygon<A>; 2]>,
) -> PlaneCut
pub fn cut( &self, poly: &Self, front: &mut SmallVec<[Polygon<A>; 2]>, back: &mut SmallVec<[Polygon<A>; 2]>, ) -> PlaneCut
Cut a polygon with another one.
Write the resulting polygons in front
and back
if the polygon needs to be split.
sourcepub fn is_aligned(&self, other: &Self) -> bool
pub fn is_aligned(&self, other: &Self) -> bool
Returns whether both polygon’s planes are parallel.