dmarx / keyframed

Simple, expressive, pythonic datatypes for manipulating curves parameterized by keyframes and interpolators.
36 stars 1 forks source link

add lowess #25

Closed dmarx closed 1 year ago

dmarx commented 1 year ago

https://en.wikipedia.org/wiki/Local_regression

tri-cube and gaussian kernels

dmarx commented 1 year ago

semi-lowess lerping:

  1. find two nearest neighbor keyframes to given index k
    • let x0 be nearest and x1 be next nearest
    • d = |x1-x0|, t = (x0-k)/d s.t. t=0 when k==x0
  2. let w = lowess(k, curve)
  3. f(k) = (1-t) x0 + (t) w

rationale here is leverage lowess smoothing while forcing function to take defined values where we have them.

as I've got it, I think this algorithm actually produces a sharp corner at d/2, which I definitely don't want.

the interpolator I'm looking for definitely exists already, I need to not reinvent the wheel here.

dmarx commented 1 year ago

way simpler: just use an interpolation method that requires a context of two observations per endpoint instead of one, e.g. cubic, hermitian, catmull-rom - http://paulbourke.net/miscellaneous/interpolation/

dmarx commented 1 year ago

maybe later...