Function simplicity::orient_1d[][src]

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

Returns whether the orientation of 2 points in 1-dimensional space is positive after perturbing them; that is, if the 1st one is to the right of the 2nd one.

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

Example

let points = vec![0.0, 1.0, 2.0, 1.0];
let positive = orient_1d(&points, |l, i| Vector1::new(l[i]), 1, 3);
// points[1] gets perturbed farther to the right than points[3]
assert!(positive);