polygon2.windingNumber
How many times the ring winds around a point, counter-clockwise turns counting +1.
Usage
polygon.windingNumber(p: Point2): numberParameters
pPoint2The point to test. Required. In model.
Returns
An integer: 0 outside, +1 inside a counter-clockwise simple ring, −1 inside a clockwise one, more for multiply wound rings; 0 for a non-finite point.
Guarantees
- for a simple ring, the result is 0 or ±1 with the sign of signedArea()
- reversed() negates it
- The same result on every machine.
Example
const sq = Polygon2.rectangle(2, 2).value.xy
Polygon2.fromFlat([...sq, ...sq]).value.windingNumber(Point2.origin) // → 2