Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-linear interpolation #12

Closed
1 of 3 tasks
LeaVerou opened this issue May 6, 2020 · 3 comments
Closed
1 of 3 tasks

Non-linear interpolation #12

LeaVerou opened this issue May 6, 2020 · 3 comments
Labels

Comments

@LeaVerou
Copy link
Member

LeaVerou commented May 6, 2020

Right now we only support linear interpolation.

We should also support:

  • Custom cubic bezier
  • Possibly keywords
  • Entirely custom functions
@LeaVerou LeaVerou added the enhancement New feature or request label May 6, 2020
@LeaVerou LeaVerou added this to the Public release milestone May 6, 2020
LeaVerou added a commit that referenced this issue May 19, 2020
@svgeesus
Copy link
Member

Interpolation with curves can produce out of gamut values due to curve overshoot. It is desirable to minimize this, and come curve interpolation methods have no overshoot.

This overview of interpolation mentions cosine interpolation, which is very straightforward code-wise and avoids the obvious discontinuities produced by linear interpolation, while having no overshoot:

linear
cosine

@svgeesus
Copy link
Member

compare

double LinearInterpolate(
   double y1,double y2,
   double mu)
{
   return(y1*(1-mu)+y2*mu);
}

with

double CosineInterpolate(
   double y1,double y2,
   double mu)
{
   double mu2;

   mu2 = (1-cos(mu*PI))/2;
   return(y1*(1-mu2)+y2*mu2);
}

@LeaVerou LeaVerou removed this from the Public release milestone Feb 9, 2024
@LeaVerou
Copy link
Member Author

LeaVerou commented Feb 9, 2024

Closing this since we already have non-linear-interpolation, and opened #410 to track shortcuts

@LeaVerou LeaVerou closed this as completed Feb 9, 2024
@LeaVerou LeaVerou added this to the Public release milestone Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants