is_simple

Function is_simple 

Source
pub fn is_simple<T>(points: &[[T; 2]]) -> bool
where T: Clone + Signed + PartialEq + PartialOrd, for<'a, 'b> &'a T: Div<&'b T, Output = T> + Sub<&'b T, Output = T> + Mul<&'b T, Output = T>,
Examples found in repository?
examples/simple.rs (line 10)
5fn main() {
6    let points = [[0.5, -0.5], [0.5, 0.5], [-0.5, 0.5], [-0.5, -0.5]];
7
8    assert_eq!(triangulate(&points), [0, 1, 2, 0, 2, 3]);
9    assert_eq!(area(&points), 1.0);
10    assert_eq!(is_simple(&points), true);
11    assert_eq!(is_convex(&points), true);
12
13    assert_eq!(contains_point(&points, &[0.0, 0.0]), true);
14    assert_eq!(contains_point(&points, &[1.0, 1.0]), false);
15
16    assert_eq!(closest_edge(&points, &[1.0, 0.0]).edge, 0);
17    assert_eq!(closest_edge(&points, &[0.0, 1.0]).edge, 1);
18    assert_eq!(closest_edge(&points, &[-1.0, 0.0]).edge, 2);
19    assert_eq!(closest_edge(&points, &[0.0, -1.0]).edge, 3);
20
21    let subject = [[1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]];
22    let clip = [[0.5, -0.5], [0.5, 0.5], [-0.5, 0.5], [-0.5, -0.5]];
23
24    let difference_polygons = difference(&subject, &clip);
25    let intersection_polygons = intersection(&subject, &clip);
26    let union_polygons = union(&subject, &clip);
27
28    assert_eq!(area(&difference_polygons[0]), 0.75);
29    assert_eq!(area(&intersection_polygons[0]), 0.25);
30    assert_eq!(area(&union_polygons[0]), 1.75);
31}