-
Notifications
You must be signed in to change notification settings - Fork 28
Interpolation Methods
osuushi edited this page Mar 14, 2012
·
2 revisions
To better understand the different interpolation modes, here are some graphs which use Smooth.js to approximate the sin function. The sin function is first sampled at 8 points, and the resulting array is fed into Smooth.js with different options. The result is plotted in magenta, with the real sin wave plotted in light green for reference.
The graphs above were generated by feeding Mac OS X's Grapher the output of the following script:
{Smooth} = require './Smooth'
s = (Math.sin 2*Math.PI*x for x in [0...1] by 1/8)
smooth_sin = Smooth s, {
clip:Smooth.CLIP_PERIODIC
method:Smooth.METHOD_LINEAR # change this for different types
}
console.log "#{x.toFixed 2}\t#{smooth_sin(x).toFixed 5}" for x in [0..8] by 0.1