#[repr(C)]pub struct Triangle<const D: usize> { /* private fields */ }Expand description
A triangle
The dimensionality of the triangle is defined by the const generic D
parameter.
Implementations§
source§impl<const D: usize> Triangle<D>
impl<const D: usize> Triangle<D>
sourcepub fn from_points(
points: [impl Into<Point<D>>; 3]
) -> Result<Self, NotATriangle<D>>
pub fn from_points(
points: [impl Into<Point<D>>; 3]
) -> Result<Self, NotATriangle<D>>
Construct a triangle from three points
Returns an error, if the points don’t form a triangle.
Examples found in repository?
More examples
src/line.rs (line 102)
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
pub fn is_coincident_with(&self, other: &Self) -> bool {
let other_origin_is_not_on_self = {
let a = other.origin;
let b = self.origin;
let c = self.origin + self.direction;
// The triangle is valid only, if the three points are not on the
// same line.
Triangle::from_points([a, b, c]).is_ok()
};
if other_origin_is_not_on_self {
return false;
}
let d1 = self.direction.normalize();
let d2 = other.direction.normalize();
d1 == d2 || d1 == -d2
}source§impl Triangle<3>
impl Triangle<3>
sourcepub fn to_parry(self) -> Triangle
pub fn to_parry(self) -> Triangle
Convert the triangle to a Parry triangle
Examples found in repository?
src/triangle.rs (line 97)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
pub fn cast_local_ray(
&self,
origin: Point<3>,
dir: Vector<3>,
max_toi: f64,
solid: bool,
) -> Option<Scalar> {
let ray = Ray {
origin: origin.to_na(),
dir: dir.to_na(),
};
self.to_parry()
.cast_local_ray(&ray, max_toi, solid)
.map(Into::into)
}
/// Compute the triangle's normal
pub fn normal(&self) -> Vector<3> {
self.to_parry()
.normal()
.expect("triangle is valid (validated on construction)")
.into_inner()
.into()
}Trait Implementations§
source§impl<const D: usize> Ord for Triangle<D>
impl<const D: usize> Ord for Triangle<D>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<const D: usize> PartialEq<Triangle<D>> for Triangle<D>
impl<const D: usize> PartialEq<Triangle<D>> for Triangle<D>
source§impl<const D: usize> PartialOrd<Triangle<D>> for Triangle<D>
impl<const D: usize> PartialOrd<Triangle<D>> for Triangle<D>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl<const D: usize> Copy for Triangle<D>
impl<const D: usize> Eq for Triangle<D>
impl<const D: usize> StructuralEq for Triangle<D>
impl<const D: usize> StructuralPartialEq for Triangle<D>
Auto Trait Implementations§
impl<const D: usize> RefUnwindSafe for Triangle<D>
impl<const D: usize> Send for Triangle<D>
impl<const D: usize> Sync for Triangle<D>
impl<const D: usize> Unpin for Triangle<D>
impl<const D: usize> UnwindSafe for Triangle<D>
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.