pub struct WeightedEdge {
pub a: WeightedVertex,
pub b: WeightedVertex,
/* private fields */
}Expand description
A weighted 1-simplex in 2-dimensional space.
Fields§
§a: WeightedVertex§b: WeightedVertexImplementations§
Source§impl WeightedEdge
impl WeightedEdge
pub fn new(a: WeightedVertex, b: WeightedVertex) -> Self
Sourcepub fn with_triangles(
a: WeightedVertex,
b: WeightedVertex,
triangles: [Option<WeightedTriangle>; 2],
) -> Self
pub fn with_triangles( a: WeightedVertex, b: WeightedVertex, triangles: [Option<WeightedTriangle>; 2], ) -> Self
Create a new edge with the given triangles as incident triangles
Sourcepub fn set_triangles(&mut self, triangles: [Option<WeightedTriangle>; 2])
pub fn set_triangles(&mut self, triangles: [Option<WeightedTriangle>; 2])
Set the incident triangles of the edge
pub fn vertices(&self) -> Vec<WeightedVertex>
Trait Implementations§
Source§impl Clone for WeightedEdge
impl Clone for WeightedEdge
Source§fn clone(&self) -> WeightedEdge
fn clone(&self) -> WeightedEdge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WeightedEdge
impl Debug for WeightedEdge
Source§impl Display for WeightedEdge
impl Display for WeightedEdge
Source§impl Hash for WeightedEdge
impl Hash for WeightedEdge
Source§impl Ord for WeightedEdge
impl Ord for WeightedEdge
Source§fn cmp(&self, other: &WeightedEdge) -> Ordering
fn cmp(&self, other: &WeightedEdge) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for WeightedEdge
impl PartialEq for WeightedEdge
Source§impl PartialOrd for WeightedEdge
impl PartialOrd for WeightedEdge
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 WeightedEdge
impl Eq for WeightedEdge
impl StructuralPartialEq for WeightedEdge
Auto Trait Implementations§
impl Freeze for WeightedEdge
impl RefUnwindSafe for WeightedEdge
impl Send for WeightedEdge
impl Sync for WeightedEdge
impl Unpin for WeightedEdge
impl UnwindSafe for WeightedEdge
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
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>
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>
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)
&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)
&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>
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>
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.