Struct plane_split::Polygon
[−]
[src]
pub struct Polygon<T, U> { pub points: [TypedPoint3D<T, U>; 4], pub normal: TypedPoint3D<T, U>, pub offset: T, pub anchor: usize, }
A convex flat polygon with 4 points, defined by equation: dot(v, normal) + offset = 0
Fields
points: [TypedPoint3D<T, U>; 4]
Points making the polygon.
normal: TypedPoint3D<T, U>
Normalized vector perpendicular to the polygon plane.
offset: T
Constant offset from the normal plane, specified in the direction opposite to the normal.
anchor: usize
A simple anchoring index to allow association of the produced split polygons with the original one.
Methods
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,
[src]
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,
fn from_transformed_rect<V>(
rect: TypedRect<T, V>,
transform: TypedMatrix4D<T, V, U>,
anchor: usize
) -> Polygon<T, U> where
T: Trig + Neg<Output = T>,
rect: TypedRect<T, V>,
transform: TypedMatrix4D<T, V, U>,
anchor: usize
) -> Polygon<T, U> where
T: Trig + Neg<Output = T>,
Construct a polygon from a transformed rectangle.
fn untransform_point(&self, point: TypedPoint3D<T, U>) -> Point2D<T>
Bring a point into the local coordinate space, returning the 2D normalized coordinates.
fn signed_distance_to(&self, point: &TypedPoint3D<T, U>) -> T
Return the signed distance from this polygon to a point. The distance is negative if the point is on the other side of the polygon from the direction of the normal.
fn distance_to_line(&self, line: &Line<T, U>) -> T where
T: Neg<Output = T>,
T: Neg<Output = T>,
Compute the distance across the line to the polygon plane, starting from the line origin.
fn signed_distance_sum_to(&self, other: &Self) -> T
Compute the sum of signed distances to each of the points
of another polygon. Useful to know the relation of a polygon that
is a product of a split, and we know it doesn't intersect self
.
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.
fn are_outside(&self, points: &[TypedPoint3D<T, U>]) -> bool
Check if a convex shape defined by a set of points is completely outside of this polygon. Merely touching the surface is not considered an intersection.
fn contains(&self, other: &Self) -> bool
Check if this polygon contains another one.
fn project_on(&self, vector: &TypedPoint3D<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.
fn intersect(&self, other: &Self) -> Intersection<Line<T, U>>
Compute the line of intersection with another polygon.
fn split(
&mut self,
line: &Line<T, U>
) -> (Option<Polygon<T, U>>, Option<Polygon<T, U>>)
&mut self,
line: &Line<T, U>
) -> (Option<Polygon<T, U>>, Option<Polygon<T, U>>)
Split the polygon along the specified Line
. Will do nothing if the line
doesn't belong to the polygon plane.
Trait Implementations
impl<T, U> Plane for 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,
[src]
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,
fn cut(&self, plane: Self) -> PlaneCut<Self>
Try to cut a different plane by this one.
fn is_aligned(&self, plane: &Self) -> bool
Check if a different plane is aligned in the same direction as this one. Read more
impl<T: Debug, U: Debug> Debug for Polygon<T, U>
[src]
impl<T: PartialEq, U: PartialEq> PartialEq for Polygon<T, U>
[src]
fn eq(&self, __arg_0: &Polygon<T, U>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Polygon<T, U>) -> bool
This method tests for !=
.
impl<T: Clone, U> Clone for Polygon<T, U>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more