pub struct Triangle2D {
pub a: [f32; 2],
pub b: [f32; 2],
pub c: [f32; 2],
}Expand description
A triangle defined by three 2D vertices.
Fields§
§a: [f32; 2]§b: [f32; 2]§c: [f32; 2]Implementations§
Source§impl Triangle2D
impl Triangle2D
pub fn new(a: [f32; 2], b: [f32; 2], c: [f32; 2]) -> Self
Sourcepub fn barycentric(&self, p: [f32; 2]) -> Option<[f32; 3]>
pub fn barycentric(&self, p: [f32; 2]) -> Option<[f32; 3]>
Compute barycentric coordinates (u, v, w) for point p. Returns None if the triangle is degenerate.
Sourcepub fn interpolate(&self, values: [f32; 3], bary: [f32; 3]) -> f32
pub fn interpolate(&self, values: [f32; 3], bary: [f32; 3]) -> f32
Interpolate a scalar value at barycentric coords (u, v, w).
Sourcepub fn signed_area(&self) -> f32
pub fn signed_area(&self) -> f32
Area of the triangle (positive for CCW).
pub fn area(&self) -> f32
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
impl Copy 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