pub fn induced_subcomplex(
vertices: &[WeightedVertex],
triangulation: &Triangulation,
) -> Vec<WeightedTriangle>Expand description
A 1-simplex and its two incident 2-simplices yield four points, of which all 2-simplices of the given triangulation that consist of any permutation of 3 of these vertices form the induced subcomplex.
More formally:
Let e be and edge of an arbitrary triangulation T and t1, t2 be it’s incident triangles (given they exist).
The induced subcomplex of the four vertices of e, t1, t2, namely V, consists of all simplices in T
spanned by vertices in V.
use cg_math::{geometry::{WeightedVertex, WeightedTriangle, Triangulation}, utils::induced_subcomplex};
// 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);
let v2 = WeightedVertex::new(8.04, 5.53, 7.53);
let v3 = WeightedVertex::new(8.53, 8.43, 1.34);
let mut triangulation = Triangulation::empty();
triangulation.triangles_mut().append(&mut vec![
WeightedTriangle::new(v0, v1, v3),
WeightedTriangle::new(v2 ,v1, v3),
WeightedTriangle::new(v2 ,v1, v0),
]);
let mut ics = induced_subcomplex(&vec![v0, v1, v2, v3], &triangulation);
ics.sort();
triangulation.triangles_mut().sort();
// Yet their induced subcomplex consists of all three triangles.
assert!(ics.len() == 3);
assert_eq!(ics, *triangulation.triangles());