MCPcopy Create free account
hub / github.com/jipegit/OSXAuditor / intersect

Function intersect

d3-3.2.8/d3.js:2869–2890  ·  view source on GitHub ↗
(a, b, two)

Source from the content-addressed store, hash-verified

2867 };
2868 }
2869 function intersect(a, b, two) {
2870 var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);
2871 var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
2872 if (!determinant) return !two && a;
2873 var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2);
2874 d3_geo_cartesianAdd(A, B);
2875 var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1);
2876 if (t2 < 0) return;
2877 var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);
2878 d3_geo_cartesianAdd(q, A);
2879 q = d3_geo_spherical(q);
2880 if (!two) return q;
2881 var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z;
2882 if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z;
2883 var δλ = λ1 - λ0, polar = Math.abs(δλ - π) < ε, meridian = polar || δλ < ε;
2884 if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z;
2885 if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (Math.abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) {
2886 var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);
2887 d3_geo_cartesianAdd(q1, A);
2888 return [ q, d3_geo_spherical(q1) ];
2889 }
2890 }
2891 function code(λ, φ) {
2892 var r = smallRadius ? radius : π - radius, code = 0;
2893 if (λ < -r) code |= 1; else if (λ > r) code |= 2;

Callers 1

clipLineFunction · 0.85

Calls 6

d3_geo_cartesianFunction · 0.85
d3_geo_cartesianCrossFunction · 0.85
d3_geo_cartesianDotFunction · 0.85
d3_geo_cartesianScaleFunction · 0.85
d3_geo_cartesianAddFunction · 0.85
d3_geo_sphericalFunction · 0.85

Tested by

no test coverage detected