MCPcopy Index your code
hub / github.com/microsoft/SandDance / resampleLineTo

Function resampleLineTo

docs/app/js/sanddance-app.js:134127–134139  ·  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

134125}
134126function resample(project, delta2) {
134127 function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) {
134128 var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;
134129 if (d2 > 4 * delta2 && depth--) {
134130 var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = (0, _mathJs.sqrt)(a * a + b * b + c * c), phi2 = (0, _mathJs.asin)(c /= m), lambda2 = (0, _mathJs.abs)((0, _mathJs.abs)(c) - 1) < (0, _mathJs.epsilon) || (0, _mathJs.abs)(lambda0 - lambda1) < (0, _mathJs.epsilon) ? (lambda0 + lambda1) / 2 : (0, _mathJs.atan2)(b, a), p = project(lambda2, phi2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2;
134131 if (dz * dz / d2 > delta2 // perpendicular projected distance
134132 || (0, _mathJs.abs)((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 // midpoint close to an end
134133 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
134134 resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream);
134135 stream.point(x2, y2);
134136 resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream);
134137 }
134138 }
134139 }
134140 return function(stream) {
134141 var lambda00, x00, y00, a00, b00, c00, lambda0, x0, y0, a0, b0, c0; // previous point
134142 var resampleStream = {

Callers 2

linePointFunction · 0.70
ringEndFunction · 0.70

Calls 1

projectFunction · 0.70

Tested by

no test coverage detected