pub struct Triangle { /* private fields */ }Expand description
A triangle in 3D space, defined by three vertices.
Implementations§
Source§impl Triangle
impl Triangle
Sourcepub fn new(a: Point3<f32>, b: Point3<f32>, c: Point3<f32>) -> Self
pub fn new(a: Point3<f32>, b: Point3<f32>, c: Point3<f32>) -> Self
Creates a new triangle from three points.
The winding order determines the normal direction via the right-hand rule: normal = (b - a) × (c - a)
Sourcepub fn normal(&self) -> Vector3<f32>
pub fn normal(&self) -> Vector3<f32>
Computes the (unnormalized) normal vector of the triangle.
The direction follows the right-hand rule based on vertex winding.
Sourcepub fn unit_normal(&self) -> Option<Vector3<f32>>
pub fn unit_normal(&self) -> Option<Vector3<f32>>
Computes the unit normal vector of the triangle.
Returns None if the triangle is degenerate (zero area).
Sourcepub fn plane(&self) -> Plane3D
pub fn plane(&self) -> Plane3D
Returns the plane that this triangle lies on.
§Panics
Panics if the triangle is degenerate (vertices are collinear).
Sourcepub fn classify(&self, plane: &Plane3D) -> Classification
pub fn classify(&self, plane: &Plane3D) -> Classification
Classifies this triangle relative to a plane.
Returns:
Frontif all vertices are in front of the planeBackif all vertices are behind the planeCoplanarif all vertices lie on the planeSpanningif vertices are on both sides
Trait Implementations§
impl StructuralPartialEq for Triangle
Auto Trait Implementations§
impl Freeze for Triangle
impl RefUnwindSafe for Triangle
impl Send for Triangle
impl Sync for Triangle
impl Unpin for Triangle
impl UnsafeUnpin for Triangle
impl UnwindSafe for Triangle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.