Evercoder / Evercoder/culori

closed interpolation outside [0, 1]?

Open
#91 8 comments 0 reactions 1 assignee Claimed by @danburzo View on GitHub
Feature
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.

![image](https://user-images.githubusercontent.com/7001/86459290-d947f500-bd26-11ea-829f-8a77ebc4a097.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.