diff --git a/math.scad b/math.scad index 10938ab..5ec3209 100644 --- a/math.scad +++ b/math.scad @@ -899,7 +899,13 @@ function count_true(l, nmax=undef, i=0, cnt=0) = // data[len(data)-1]. This function uses a symetric derivative approximation // for internal points, f'(t) = (f(t+h)-f(t-h))/2h. For the endpoints (when closed=false) the algorithm // uses a two point method if sufficient points are available: f'(t) = (3*(f(t+h)-f(t)) - (f(t+2*h)-f(t+h)))/2h. +// +// If `h` is a vector then it is assumed to be nonuniform, with h[i] giving the sampling distance +// between data[i+1] and data[i], and the data values will be linearly resampled at each corner +// to produce a uniform spacing for the derivative estimate. At the endpoints a single point method +// is used: f'(t) = (f(t+h)-f(t))/h. function deriv(data, h=1, closed=false) = + is_vector(h) ? _deriv_nonuniform(data, h, closed=closed) : let( L = len(data) ) closed? [ for(i=[0:1:L-1]) @@ -919,6 +925,28 @@ function deriv(data, h=1, closed=false) = ]; +function _dnu_calc(f1,fc,f2,h1,h2) = + let( + f1 = h2