closed interpolation outside [0, 1]?
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
I wanted to use the closed interpolator outside [0,1], so in principle I thought it would be periodic; but in fact its domain is [0, 1 + 1/n], and it "crashes" outside.
Here's how I "fix" this:
~~~
culoriClosed = array => {
const f = culori.interpolateSplineMonotone(d => d, "closed", 1)(array),
n = array.length - 1,
k = 1 + 1 / n;
return t => f(k * (t - Math.floor(t)));
}
~~~
now the domain of culoriClosed is [0, 1] (we have a complete curve if *t* in [0, 1]), and we have f(t + integer) === f(t).
https://observablehq.com/d/f2e94a3321c17726 draws a spiral with -5 < t < 30, and the main domain as a loop, in heavy black.

Contributor guide
Assessment
This issue has not been assessed yet.