#[repr(transparent)]pub struct Tri<V>(pub [V; 3]);Expand description
Triangle, defined by three vertices.
Tuple Fields§
§0: [V; 3]Implementations§
Source§impl<V> Tri<V>
impl<V> Tri<V>
Sourcepub fn edges(&self) -> [Edge<&V>; 3]
pub fn edges(&self) -> [Edge<&V>; 3]
Given a triangle ABC, returns the edges [AB, BC, CA].
§Examples
use retrofire_core::geom::{Tri, Edge};
use retrofire_core::math::{Point2, pt2};
let pts: [Point2; _] = [pt2(-1.0, 0.0), pt2(2.0, 0.0), pt2(1.0, 2.0)];
let tri = Tri(pts);
let [e0, e1, e2] = tri.edges();
assert_eq!(e0, Edge(&pts[0], &pts[1]));
assert_eq!(e1, Edge(&pts[1], &pts[2]));
assert_eq!(e2, Edge(&pts[2], &pts[0]));
Source§impl<A, B> Tri<Vertex2<A, B>>
impl<A, B> Tri<Vertex2<A, B>>
Sourcepub fn winding(&self) -> Winding
pub fn winding(&self) -> Winding
Returns the winding order of self.
§Examples
use retrofire_core::geom::{Tri, vertex, Winding};
use retrofire_core::math::pt2;
let mut tri = Tri([
vertex(pt2::<_, ()>(0.0, 0.0), ()),
vertex(pt2(0.0, 3.0), ()),
vertex(pt2(4.0, 0.0), ()),
]);
assert_eq!(tri.winding(), Winding::Cw);
tri.0.swap(1, 2);
assert_eq!(tri.winding(), Winding::Ccw);Sourcepub fn signed_area(&self) -> f32
pub fn signed_area(&self) -> f32
Returns the signed area of self.
The area is positive iff self is wound counter-clockwise.
§Examples
use retrofire_core::geom::{Tri, vertex};
use retrofire_core::math::pt2;
let tri = Tri([
vertex(pt2::<_, ()>(0.0, 0.0), ()),
vertex(pt2(0.0, 3.0), ()),
vertex(pt2(4.0, 0.0), ()),
]);
assert_eq!(tri.signed_area(), -6.0);Source§impl<A, B> Tri<Vertex3<A, B>>
impl<A, B> Tri<Vertex3<A, B>>
Sourcepub fn normal(&self) -> Normal3
pub fn normal(&self) -> Normal3
Returns the normal vector of self.
The result is normalized to unit length.
§Examples
use core::f32::consts::SQRT_2;
use retrofire_core::geom::{Tri, vertex};
use retrofire_core::math::{pt3, vec3};
// Triangle lying in a 45° angle
let tri = Tri([
vertex(pt3::<_, ()>(0.0, 0.0, 0.0), ()),
vertex(pt3(0.0, 3.0, 3.0), ()),
vertex(pt3(4.0, 0.0,0.0), ()),
]);
assert_eq!(tri.normal(), vec3(0.0, SQRT_2 / 2.0, -SQRT_2 / 2.0));Sourcepub fn plane(&self) -> Plane3<B>
pub fn plane(&self) -> Plane3<B>
Returns the plane that self lies on.
§Examples
use retrofire_core::geom::{Tri, Plane3, vertex};
use retrofire_core::math::{pt3, Vec3};
let tri = Tri([
vertex(pt3::<f32, ()>(0.0, 0.0, 2.0), ()),
vertex(pt3(1.0, 0.0, 2.0), ()),
vertex(pt3(0.0, 1.0, 2.0), ())
]);
assert_eq!(tri.plane().normal(), Vec3::Z);
assert_eq!(tri.plane().offset(), 2.0);Trait Implementations§
Source§impl<V: Vary> Render<V> for Tri<usize>
impl<V: Vary> Render<V> for Tri<usize>
Source§type Screen = Tri<Vertex<Point<[f32; 3], Real<3, Screen>>, V>>
type Screen = Tri<Vertex<Point<[f32; 3], Real<3, Screen>>, V>>
The type of this primitive in screen space.
Source§fn inline(ixd: Tri<usize>, vs: &[ClipVert<V>]) -> Tri<ClipVert<V>>
fn inline(ixd: Tri<usize>, vs: &[ClipVert<V>]) -> Tri<ClipVert<V>>
Maps the indexes of the argument to vertices.
Source§fn is_backface(tri: &Self::Screen) -> bool
fn is_backface(tri: &Self::Screen) -> bool
Returns whether the argument is facing away from the camera.
impl<V: Copy> Copy for Tri<V>
impl<V: Eq> Eq for Tri<V>
impl<V> StructuralPartialEq for Tri<V>
Auto Trait Implementations§
impl<V> Freeze for Tri<V>where
V: Freeze,
impl<V> RefUnwindSafe for Tri<V>where
V: RefUnwindSafe,
impl<V> Send for Tri<V>where
V: Send,
impl<V> Sync for Tri<V>where
V: Sync,
impl<V> Unpin for Tri<V>where
V: Unpin,
impl<V> UnwindSafe for Tri<V>where
V: UnwindSafe,
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