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

Function bimap

docs/app/js/sanddance-app.js:127485–127492  ·  view source on GitHub ↗
(domain, range, interpolate)

Source from the content-addressed store, hash-verified

127483// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
127484// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
127485function bimap(domain, range, interpolate) {
127486 var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
127487 if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
127488 else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
127489 return function(x) {
127490 return r0(d0(x));
127491 };
127492}
127493function polymap(domain, range, interpolate) {
127494 var j = Math.min(domain.length, range.length) - 1, d = new Array(j), r = new Array(j), i1 = -1;
127495 // Reverse descending domains.

Callers

nothing calls this directly

Calls 2

normalizeFunction · 0.70
interpolateFunction · 0.70

Tested by

no test coverage detected