MCPcopy Create free account
hub / github.com/microsoft/SandDance / ringContains

Function ringContains

docs/app/js/sanddance-app.js:130615–130623  ·  view source on GitHub ↗
(ring, point)

Source from the content-addressed store, hash-verified

130613 return 0;
130614}
130615function ringContains(ring, point) {
130616 var x = point[0], y = point[1], contains1 = -1;
130617 for(var i = 0, n = ring.length, j = n - 1; i < n; j = i++){
130618 var pi = ring[i], xi = pi[0], yi = pi[1], pj = ring[j], xj = pj[0], yj = pj[1];
130619 if (segmentContains(pi, pj, point)) return 0;
130620 if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) contains1 = -contains1;
130621 }
130622 return contains1;
130623}
130624function segmentContains(a, b, c) {
130625 var i;
130626 return collinear(a, b, c) && within(a[i = +(a[0] === b[0])], c[i], b[i]);

Callers 1

containsFunction · 0.70

Calls 1

segmentContainsFunction · 0.70

Tested by

no test coverage detected