MCPcopy Index your code
hub / github.com/jipegit/OSXAuditor / insidePolygon

Function insidePolygon

d3-3.2.8/d3.js:2932–2946  ·  view source on GitHub ↗
(p)

Source from the content-addressed store, hash-verified

2930 return i;
2931 }
2932 function insidePolygon(p) {
2933 var wn = 0, n = polygon.length, y = p[1];
2934 for (var i = 0; i < n; ++i) {
2935 for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
2936 b = v[j];
2937 if (a[1] <= y) {
2938 if (b[1] > y && isLeft(a, b, p) > 0) ++wn;
2939 } else {
2940 if (b[1] <= y && isLeft(a, b, p) < 0) --wn;
2941 }
2942 a = b;
2943 }
2944 }
2945 return wn !== 0;
2946 }
2947 function isLeft(a, b, c) {
2948 return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]);
2949 }

Callers 2

d3_geo_clipViewFunction · 0.85
insideFunction · 0.85

Calls 1

isLeftFunction · 0.85

Tested by

no test coverage detected