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

Function controlPoints

docs/app/js/sanddance-app.js:126467–126481  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

126465};
126466// See https://www.particleincell.com/2012/bezier-splines/ for derivation.
126467function controlPoints(x) {
126468 var i, n = x.length - 1, m, a = new Array(n), b = new Array(n), r = new Array(n);
126469 a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1];
126470 for(i = 1; i < n - 1; ++i)a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1];
126471 a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n];
126472 for(i = 1; i < n; ++i)m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1];
126473 a[n - 1] = r[n - 1] / b[n - 1];
126474 for(i = n - 2; i >= 0; --i)a[i] = (r[i] - a[i + 1]) / b[i];
126475 b[n - 1] = (x[n] + a[n - 1]) / 2;
126476 for(i = 0; i < n - 1; ++i)b[i] = 2 * x[i + 1] - a[i + 1];
126477 return [
126478 a,
126479 b
126480 ];
126481}
126482exports.default = function(context) {
126483 return new Natural(context);
126484};

Callers 1

sanddance-app.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected