- Updated all component headers and documentation
- Changed navbar and footer branding
- Updated homepage hero badge
- Modified page title in index.html
- Simplified footer text to 'Built with ❤️'
- Consistent V2 capitalization across all references
28 lines
871 B
JavaScript
28 lines
871 B
JavaScript
export default function(ring, hole) {
|
|
var i = -1, n = hole.length, c;
|
|
while (++i < n) if (c = ringContains(ring, hole[i])) return c;
|
|
return 0;
|
|
}
|
|
|
|
function ringContains(ring, point) {
|
|
var x = point[0], y = point[1], contains = -1;
|
|
for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
|
|
var pi = ring[i], xi = pi[0], yi = pi[1], pj = ring[j], xj = pj[0], yj = pj[1];
|
|
if (segmentContains(pi, pj, point)) return 0;
|
|
if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) contains = -contains;
|
|
}
|
|
return contains;
|
|
}
|
|
|
|
function segmentContains(a, b, c) {
|
|
var i; return collinear(a, b, c) && within(a[i = +(a[0] === b[0])], c[i], b[i]);
|
|
}
|
|
|
|
function collinear(a, b, c) {
|
|
return (b[0] - a[0]) * (c[1] - a[1]) === (c[0] - a[0]) * (b[1] - a[1]);
|
|
}
|
|
|
|
function within(p, q, r) {
|
|
return p <= q && q <= r || r <= q && q <= p;
|
|
}
|