On Sat, Jun 28, 2008 at 7:43 AM, cyrille henry <[EMAIL PROTECTED]> wrote: > > > Matt Barber a écrit : > ... > >> >> The following bit of code might work to that end as a test, borrowing >> Cyrille's general notation: >> >> >> cminusb = c-b; >> aminusd = a-d; >> >> a0 = aminusd + 3.0 * cminusb; >> a1 = -2.5f * aminusd - 7.5f * cminusb; >> a2 = 1.5f * aminusd + 4.5f * cminusb; >> a3 = 0.5f * (c + a) - b; >> a4 = 0.5f * (c - a); >> a5 = b; >> >> *out++ = ((((a0*frac+a1)*frac+a2)*frac+a3)*frac+a4)*frac+a5; >> > ok, i'll try that. > but i don't think adjusting the 2nd derivative is the best thing to do. > for me, having a 6 point interpolation would be more important. > > well, we will see... > >>
This would work, as well. Changing the coefficient order to match the previous code (sorry I bollixed that up before). a4 and a3 are simple ratios of a5, but keeping a2 as explicitly the fourth coefficient... dropping a0, aminusd, and cminusb: a5 = a - d + 3.0f * (c - b); a2 = 0.5f * (c + a) - b; a1 = 0.5f * (c - a); *out++ = ((((a5*frac-2.5f*a5)*frac+1.5*a5)*frac+a2)*frac+a1)*frac+b; I count 11 adds and 10 multiplies, vs. 9 +'s and 7 *'s in the original Lagrange algorithm in Pd, and 10 +'s and 9 *'s in the "third order Hermite" example. I don't know if it's as simple as all that, though, but it would seem to be on at least a similar order of performance. BTW, the following for the C1 interpolation might be slightly more efficient (I left the original line commented out): a1 = 0.5f * (c - a); /* a2 = a - 2.5 * b + 2.f * c - 0.5f * d; */ a3 = 0.5f * (d - a) + 1.5f * (b - c); a2 = a - b + a1 - a3; *out++ = ((a3 * frac + a2) * frac + a1) * frac + b; . 10 +'s 6 *'s Matt _______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
