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,

source

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.

source

pub fn from_rect(rect: Rect<f64>, anchor: A) -> Self

Construct a polygon from a non-transformed rectangle.

source

pub fn from_transformed_rect( rect: Rect<f64>, transform: Transform3D<f64>, anchor: A ) -> Option<Self>

Construct a polygon from a rectangle with 3D transform.

source

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.

source

pub fn untransform_point(&self, point: Point3D<f64>) -> Point2D<f64>

Bring a point into the local coordinate space, returning the 2D normalized coordinates.

source

pub fn transform(&self, transform: &Transform3D<f64>) -> Option<Polygon<A>>

Transform a polygon by an affine transform (preserving straight lines).

source

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.

source

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.

source

pub fn contains(&self, other: &Self) -> bool

Check if this polygon contains another one.

source

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.

source

pub fn intersect_plane(&self, other: &Plane) -> Intersection<Line>

Compute the line of intersection with an infinite plane.

source

pub fn intersect(&self, other: &Self) -> Intersection<Line>

Compute the line of intersection with another polygon.

source

fn split_impl( &mut self, first: (usize, Point3D<f64>), second: (usize, Point3D<f64>) ) -> (Option<Self>, Option<Self>)

source

pub fn split(&mut self, line: &Line) -> (Option<Self>, Option<Self>)

👎Deprecated: Use split_with_normal instead

Split the polygon along the specified Line. Will do nothing if the line doesn’t belong to the polygon plane.

source

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.

source

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.

source

pub fn is_aligned(&self, other: &Self) -> bool

Returns whether both polygon’s planes are parallel.

Trait Implementations§

source§

impl<A: Copy> Clone for Polygon<A>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A: Debug> Debug for Polygon<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A: PartialEq> PartialEq<Polygon<A>> for Polygon<A>

source§

fn eq(&self, other: &Polygon<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A> StructuralPartialEq for Polygon<A>

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for Polygon<A>where A: RefUnwindSafe,

§

impl<A> Send for Polygon<A>where A: Send,

§

impl<A> Sync for Polygon<A>where A: Sync,

§

impl<A> Unpin for Polygon<A>where A: Unpin,

§

impl<A> UnwindSafe for Polygon<A>where A: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.