javascript - How to call Monotonic Spline function -
let me preface with, i'm not math whiz means. interested in fitting curve monotonic spline function data.
i trying javascript version of monotonic spline function work , can't figure out how call function properly. specifically, beginning of code starts (i've never seen function named in manner before):
var cubicspline, monotoniccubicspline; monotoniccubicspline = function() { function monotoniccubicspline(x, y) {
to me, same function defined in 2 different scopes. first doesn't take parameters , second 1 does. how around this?
i started supplying points wanted fit:
monotoniccubicspline([0,5,10,15,20,25], [0,6,2,6,7,10])
but portion of function doesn't return anything, seems if need call function same name above that. if want test out, here's jsfiddle link:
any appreciated! thanks!
credit function goes to: http://blog.mackerron.com/2011/01/01/javascript-cubic-splines/
in monotoniccubicspline function declaration, can see there interpolate function added prototype , constructor function returns nothing.
so have declare new monotoniccubicspline use interpolate function.
example:
var myspline = new monotoniccubicspline([0,5,10,15,20,25], [0,6,2,6,7,10]); console.log(myspline.interpolate(3));
i'm not sure suppose interpolate function argument abscissa.
Comments
Post a Comment