Main Archive Specials Wiki | FAQ Links Submit Forum

 Hermite interpollationReferences : Posted by variousNotes : These are all different ways to do the same thing : hermite interpollation. Try'm all and benchmark.Code : // original inline float hermite1(float x, float y0, float y1, float y2, float y3) { // 4-point, 3rd-order Hermite (x-form) float c0 = y1; float c1 = 0.5f * (y2 - y0); float c2 = y0 - 2.5f * y1 + 2.f * y2 - 0.5f * y3; float c3 = 1.5f * (y1 - y2) + 0.5f * (y3 - y0); return ((c3 * x + c2) * x + c1) * x + c0; } // james mccartney inline float hermite2(float x, float y0, float y1, float y2, float y3) { // 4-point, 3rd-order Hermite (x-form) float c0 = y1; float c1 = 0.5f * (y2 - y0); float c3 = 1.5f * (y1 - y2) + 0.5f * (y3 - y0); float c2 = y0 - y1 + c1 - c3; return ((c3 * x + c2) * x + c1) * x + c0; } // james mccartney inline float hermite3(float x, float y0, float y1, float y2, float y3) { // 4-point, 3rd-order Hermite (x-form) float c0 = y1; float c1 = 0.5f * (y2 - y0); float y0my1 = y0 - y1; float c3 = (y1 - y2) + 0.5f * (y3 - y0my1 - y2); float c2 = y0my1 + c1 - c3; return ((c3 * x + c2) * x + c1) * x + c0; } // laurent de soras inline float hermite4(float frac_pos, float xm1, float x0, float x1, float x2) { const float c = (x1 - xm1) * 0.5f; const float v = x0 - x1; const float w = c + v; const float a = w + v + (x2 - x0) * 0.5f; const float b_neg = w + a; return ((((a * frac_pos) - b_neg) * frac_pos + c) * frac_pos + x0); }