interpolateBalanced?
Fil opened this issue · 3 comments
Fil commented
interpolateRound(0,2) gives more space to intermediate values (1) than to the ends (0 and 2). interpolateBalanced would give them equal space.
mbostock commented
Feels too niche to me.
jrus commented
Can’t you just..
draw(interpolateRound(-0.5, 2.5))
Fil commented
No, there are tiny bugs with that formula (at the ends, in your case -0 (sort-of okay, my formula does this too) and 3 ❌).
but we can adapt it a bit:
interpolateBalanced = (a, b) => {
// epsilon is needed to have an exact value for t=1
var sign = Math.sign(b - a);
return interpolateRound(
a - sign * (0.5 - epsilon),
b + sign * (0.5 - epsilon)
);
}