MCPcopy Create free account
hub / github.com/breck7/scroll / resampleLineTo

Function resampleLineTo

external/.d3.js:12122–12147  ·  view source on GitHub ↗
(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream)

Source from the content-addressed store, hash-verified

12120function resample$1(project, delta2) {
12121
12122 function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) {
12123 var dx = x1 - x0,
12124 dy = y1 - y0,
12125 d2 = dx * dx + dy * dy;
12126 if (d2 > 4 * delta2 && depth--) {
12127 var a = a0 + a1,
12128 b = b0 + b1,
12129 c = c0 + c1,
12130 m = sqrt$2(a * a + b * b + c * c),
12131 phi2 = asin$1(c /= m),
12132 lambda2 = abs$1(abs$1(c) - 1) < epsilon$1 || abs$1(lambda0 - lambda1) < epsilon$1 ? (lambda0 + lambda1) / 2 : atan2$1(b, a),
12133 p = project(lambda2, phi2),
12134 x2 = p[0],
12135 y2 = p[1],
12136 dx2 = x2 - x0,
12137 dy2 = y2 - y0,
12138 dz = dy * dx2 - dx * dy2;
12139 if (dz * dz / d2 > delta2 // perpendicular projected distance
12140 || abs$1((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 // midpoint close to an end
12141 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { // angular distance
12142 resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream);
12143 stream.point(x2, y2);
12144 resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream);
12145 }
12146 }
12147 }
12148 return function(stream) {
12149 var lambda00, x00, y00, a00, b00, c00, // first point
12150 lambda0, x0, y0, a0, b0, c0; // previous point

Callers 2

linePointFunction · 0.85
ringEndFunction · 0.85

Calls 3

asin$1Function · 0.85
projectFunction · 0.85
pointMethod · 0.45

Tested by

no test coverage detected