vectordraw 0.1.2

A library for vector drawing with multiple output types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pub fn is_clockwise(pts: &[(f64, f64)]) -> bool {
    assert!(pts.len() > 0);
    let mut total = 0.0;
    for slice in pts.windows(2) {
        let a = slice[0];
        let b = slice[1];
        total += (b.0 - a.0) * (b.1 + a.1);
    }
    {
        let a = pts[0];
        let b = pts[pts.len() - 1];
        total += (b.0 - a.0) * (b.1 + a.1);
    }
    total > 0.0
}