vectorphile 0.1.10

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
16
17
use euclid::TypedPoint2D;

pub fn is_clockwise<K>(pts: &[TypedPoint2D<f32, K>]) -> bool {
    assert!(pts.len() > 0);
    let mut total = 0.0f32;
    for slice in pts.windows(2) {
        let a = slice[0];
        let b = slice[1];
        total += (b.x - a.x) * (b.y + a.y);
    }
    {
        let a = pts[0];
        let b = pts[pts.len() - 1];
        total += (b.x - a.x) * (b.y + a.y);
    }
    total > 0.0
}