pub struct Triangle { /* private fields */ }Expand description
A constructed 2D triangle represented by three vertices.
Implementations§
Source§impl Triangle
impl Triangle
Sourcepub const fn new(a: Point2, b: Point2, c: Point2) -> Self
pub const fn new(a: Point2, b: Point2, c: Point2) -> Self
Creates a triangle from three points.
Sourcepub fn try_new(a: Point2, b: Point2, c: Point2) -> Result<Self, GeometryError>
pub fn try_new(a: Point2, b: Point2, c: Point2) -> Result<Self, GeometryError>
Creates a triangle from three points with finite coordinates.
§Errors
Returns GeometryError::NonFiniteComponent when any vertex contains a
non-finite coordinate.
Sourcepub fn twice_signed_area(self) -> f64
pub fn twice_signed_area(self) -> f64
Returns twice the signed area of the triangle.
Sourcepub fn twice_area(self) -> f64
pub fn twice_area(self) -> f64
Returns twice the unsigned area of the triangle.
Sourcepub fn orientation(self) -> Orientation2
pub fn orientation(self) -> Orientation2
Returns the triangle orientation implied by the vertex winding order.
Sourcepub fn is_degenerate(self) -> bool
pub fn is_degenerate(self) -> bool
Returns true when the triangle is exactly degenerate.
Sourcepub fn is_degenerate_with_tolerance(
self,
tolerance: f64,
) -> Result<bool, GeometryError>
pub fn is_degenerate_with_tolerance( self, tolerance: f64, ) -> Result<bool, GeometryError>
Returns true when the triangle’s unsigned twice-area is within tolerance of zero.
§Errors
Returns GeometryError::NonFiniteTolerance when tolerance is NaN
or infinite.
Returns GeometryError::NegativeTolerance when tolerance is negative.
Trait Implementations§
impl Copy for Triangle
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