Struct plane_split::Polygon
source · pub struct Polygon<T, U> {
pub points: [TypedPoint3D<T, U>; 4],
pub plane: Plane<T, U>,
pub anchor: usize,
}Expand description
A convex polygon with 4 points lying on a plane.
Fields§
§points: [TypedPoint3D<T, U>; 4]Points making the polygon.
plane: Plane<T, U>A plane describing polygon orientation.
anchor: usizeA simple anchoring index to allow association of the produced split polygons with the original one.
Implementations§
source§impl<T, U> Polygon<T, U>where
T: Copy + Debug + ApproxEq<T> + Sub<T, Output = T> + Add<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Zero + One + Float,
U: Debug,
impl<T, U> Polygon<T, U>where
T: Copy + Debug + ApproxEq<T> + Sub<T, Output = T> + Add<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T> + Zero + One + Float,
U: Debug,
sourcepub fn from_points(
points: [TypedPoint3D<T, U>; 4],
anchor: usize
) -> Option<Self>
pub fn from_points(
points: [TypedPoint3D<T, U>; 4],
anchor: usize
) -> 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: TypedRect<T, U>, anchor: usize) -> Self
pub fn from_rect(rect: TypedRect<T, U>, anchor: usize) -> Self
Construct a polygon from a non-transformed rectangle.
sourcepub fn from_transformed_rect<V>(
rect: TypedRect<T, V>,
transform: TypedTransform3D<T, V, U>,
anchor: usize
) -> Option<Self>where
T: Trig + Neg<Output = T>,
pub fn from_transformed_rect<V>(
rect: TypedRect<T, V>,
transform: TypedTransform3D<T, V, U>,
anchor: usize
) -> Option<Self>where
T: Trig + Neg<Output = T>,
Construct a polygon from a rectangle with 3D transform.
sourcepub fn from_transformed_rect_with_inverse<V>(
rect: TypedRect<T, V>,
transform: &TypedTransform3D<T, V, U>,
inv_transform: &TypedTransform3D<T, U, V>,
anchor: usize
) -> Option<Self>where
T: Trig + Neg<Output = T>,
pub fn from_transformed_rect_with_inverse<V>(
rect: TypedRect<T, V>,
transform: &TypedTransform3D<T, V, U>,
inv_transform: &TypedTransform3D<T, U, V>,
anchor: usize
) -> Option<Self>where
T: Trig + Neg<Output = T>,
Construct a polygon from a rectangle with an invertible 3D transform.
sourcepub fn untransform_point(&self, point: TypedPoint3D<T, U>) -> Point2D<T>
pub fn untransform_point(&self, point: TypedPoint3D<T, U>) -> Point2D<T>
Bring a point into the local coordinate space, returning the 2D normalized coordinates.
sourcepub fn transform<V>(
&self,
transform: &TypedTransform3D<T, U, V>
) -> Option<Polygon<T, V>>where
T: Trig,
V: Debug,
pub fn transform<V>(
&self,
transform: &TypedTransform3D<T, U, V>
) -> Option<Polygon<T, V>>where
T: Trig,
V: Debug,
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: &TypedVector3D<T, U>) -> LineProjection<T>
pub fn project_on(&self, vector: &TypedVector3D<T, U>) -> LineProjection<T>
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<T, U>) -> Intersection<Line<T, U>>
pub fn intersect_plane(&self, other: &Plane<T, U>) -> Intersection<Line<T, U>>
Compute the line of intersection with an infinite plane.
sourcepub fn intersect(&self, other: &Self) -> Intersection<Line<T, U>>
pub fn intersect(&self, other: &Self) -> Intersection<Line<T, U>>
Compute the line of intersection with another polygon.