pub struct WeightedTriangle {
pub a: WeightedVertex,
pub b: WeightedVertex,
pub c: WeightedVertex,
}Expand description
A weighted 2-simplex in 2-dimensional space.
Fields§
§a: WeightedVertex§b: WeightedVertex§c: WeightedVertexImplementations§
Source§impl WeightedTriangle
impl WeightedTriangle
pub fn new(a: WeightedVertex, b: WeightedVertex, c: WeightedVertex) -> Self
Sourcepub fn get_third_point(&self, edge: &WeightedEdge) -> WeightedVertex
pub fn get_third_point(&self, edge: &WeightedEdge) -> WeightedVertex
Given an edge of the triangle retrieve the point not on the edge
Trait Implementations§
Source§impl Clone for WeightedTriangle
impl Clone for WeightedTriangle
Source§fn clone(&self) -> WeightedTriangle
fn clone(&self) -> WeightedTriangle
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 WeightedTriangle
impl Debug for WeightedTriangle
Source§impl Display for WeightedTriangle
impl Display for WeightedTriangle
Source§impl From<&WeightedTriangle> for PlotPoints
impl From<&WeightedTriangle> for PlotPoints
Source§fn from(triangle: &WeightedTriangle) -> Self
fn from(triangle: &WeightedTriangle) -> Self
Converts to this type from the input type.
Source§impl Hash for WeightedTriangle
impl Hash for WeightedTriangle
Source§impl Ord for WeightedTriangle
impl Ord for WeightedTriangle
Source§fn cmp(&self, other: &WeightedTriangle) -> Ordering
fn cmp(&self, other: &WeightedTriangle) -> Ordering
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 PartialEq for WeightedTriangle
impl PartialEq for WeightedTriangle
Source§impl PartialOrd for WeightedTriangle
impl PartialOrd for WeightedTriangle
Source§impl TriangleLogic<WeightedVertex, WeightedEdge, WeightedTriangle> for WeightedTriangle
impl TriangleLogic<WeightedVertex, WeightedEdge, WeightedTriangle> for WeightedTriangle
Source§fn area(&self) -> f64
fn area(&self) -> f64
The area of the triangle.
§Example
use cg_math::geometry::{WeightedVertex, WeightedTriangle, TriangleLogic};
let v0 = WeightedVertex::new(2.5, 2.0, 0.0);
let v1 = WeightedVertex::new(1.0, 2.5, 0.0);
let v2 = WeightedVertex::new(2.0, 3.0, 0.0);
let triangle = WeightedTriangle::new(v0, v1, v2);
assert_eq!(triangle.area(), 0.625);Source§fn area3d(&self) -> f64
fn area3d(&self) -> f64
The area of the triangle lifted to 3d with $z = x^2 + y^2 - w$.
§Example
use cg_math::geometry::{WeightedVertex, WeightedTriangle, TriangleLogic};
let v0 = WeightedVertex::new(2.5, 2.0, 1.0);
let v1 = WeightedVertex::new(1.0, 2.5, 2.0);
let v2 = WeightedVertex::new(2.0, 3.0, 3.0);
let triangle = WeightedTriangle::new(v0, v1, v2);
//assert_eq!(triangle.area3d(), 1.3975424859373686);Source§fn has_edge(&self, edge: &WeightedEdge) -> bool
fn has_edge(&self, edge: &WeightedEdge) -> bool
Check if the given edge is part of the triangle.
Source§fn has_vertex(&self, vertex: &WeightedVertex) -> bool
fn has_vertex(&self, vertex: &WeightedVertex) -> bool
Check if the given vertex is part of the triangle.
Source§fn is_regular(&self, vertex: &WeightedVertex) -> bool
fn is_regular(&self, vertex: &WeightedVertex) -> bool
Check whether the triangle is regular w.r.t to the given vertex.
use cg_math::{geometry::{WeightedVertex, WeightedTriangle, TriangleLogic}, utils::c_hull};
// these 4 vertices span two of the three triangles in the triangulation
let v0 = WeightedVertex::new(6.24, 8.38, 2.24);
let v1 = WeightedVertex::new(9.34, 9.19, 7.46); // assume this one was inserted last
let v2 = WeightedVertex::new(8.04, 5.53, 7.53);
let v3 = WeightedVertex::new(8.53, 8.43, 1.34);
assert_eq!(WeightedTriangle::new(v0, v2, v3).is_regular(&v1), false);Source§fn is_eps_regular(&self, vertex: &WeightedVertex, epsilon: f64) -> bool
fn is_eps_regular(&self, vertex: &WeightedVertex, epsilon: f64) -> bool
Check whether the triangle is regular w.r.t to the given vertex; by tolerance of epsilon.
Source§fn orientation(&self) -> f64
fn orientation(&self) -> f64
The orientation of the triangle; clockwise (cw) or counter-cw.
§Panics
If the triangle consists of three collinear points.
Source§fn regularity(&self, vertex: &WeightedVertex) -> f64
fn regularity(&self, vertex: &WeightedVertex) -> f64
Compute the level of local regularity w.r.t to the given vertex
Source§fn is_neighbor(&self, other: &WeightedTriangle) -> Option<WeightedEdge>
fn is_neighbor(&self, other: &WeightedTriangle) -> Option<WeightedEdge>
Check if this and the other triangle share an edge, i.e. are neighbors and return it if existing
fn edges(&self) -> Vec<WeightedEdge>
fn vertices(&self) -> Vec<WeightedVertex>
impl Copy for WeightedTriangle
impl Eq for WeightedTriangle
impl StructuralPartialEq for WeightedTriangle
Auto Trait Implementations§
impl Freeze for WeightedTriangle
impl RefUnwindSafe for WeightedTriangle
impl Send for WeightedTriangle
impl Sync for WeightedTriangle
impl Unpin for WeightedTriangle
impl UnwindSafe for WeightedTriangle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.