[][src]Function simplicity::orient_3d

pub fn orient_3d<T: ?Sized, Idx: Ord + Copy>(
    list: &T,
    index_fn: impl Fn(&T, Idx) -> Vector3<f64>,
    i: Idx,
    j: Idx,
    k: Idx,
    l: Idx
) -> bool

Returns whether the orientation of 4 points in 3-dimensional space is positive after perturbing them; that is, if the last 3 points form a left turn when visited in order, looking from the first point.

Takes a list of all the points in consideration, an indexing function, and 4 indexes to the points to calculate the orientation of.

Example

let points = vec![
    Vector3::new(0.0, 0.0, 0.0),
    Vector3::new(1.0, 0.0, 0.0),
    Vector3::new(1.0, 1.0, 1.0),
    Vector3::new(2.0, -2.0, 0.0),
    Vector3::new(2.0, 3.0, 4.0),
    Vector3::new(0.0, 0.0, 1.0),
    Vector3::new(0.0, 1.0, 0.0),
    Vector3::new(3.0, 4.0, 5.0),
];
let positive = orient_3d(&points, |l, i| l[i], 0, 1, 6, 5);
assert!(!positive);
let positive = orient_3d(&points, |l, i| l[i], 7, 4, 0, 2);
assert!(positive);