pub struct Triangle2D {
pub a: Point2D,
pub b: Point2D,
pub c: Point2D,
}Expand description
A triangle defined by three 2D vertices.
Fields§
§a: Point2DFirst vertex.
b: Point2DSecond vertex.
c: Point2DThird vertex.
Implementations§
Source§impl Triangle2D
impl Triangle2D
Sourcepub fn signed_area(&self) -> f64
pub fn signed_area(&self) -> f64
Computes the signed area using the shoelace formula.
Positive for counter-clockwise, negative for clockwise.
Sourcepub fn is_clockwise(&self) -> bool
pub fn is_clockwise(&self) -> bool
Returns true if the vertices are arranged clockwise.
Sourcepub fn centroid(&self) -> Point2D
pub fn centroid(&self) -> Point2D
Computes the centroid (arithmetic mean of the three vertices).
Sourcepub fn contains_point(&self, p: Point2D) -> bool
pub fn contains_point(&self, p: Point2D) -> bool
Tests whether a point is inside or on the boundary of the triangle.
Uses barycentric coordinates.
Trait Implementations§
Source§impl Clone for Triangle2D
impl Clone for Triangle2D
Source§fn clone(&self) -> Triangle2D
fn clone(&self) -> Triangle2D
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Triangle2D
impl Debug for Triangle2D
Source§impl PartialEq for Triangle2D
impl PartialEq for Triangle2D
impl Copy for Triangle2D
impl StructuralPartialEq for Triangle2D
Auto Trait Implementations§
impl Freeze for Triangle2D
impl RefUnwindSafe for Triangle2D
impl Send for Triangle2D
impl Sync for Triangle2D
impl Unpin for Triangle2D
impl UnsafeUnpin for Triangle2D
impl UnwindSafe for Triangle2D
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