Main Archive Specials Wiki | FAQ Links Submit Forum


Hermite interpollation

References : Posted by various

Notes :
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);
}



Comments


Added on : 25/05/02 by theguylle
Comment :
              great sources but what is Hermite ?
if you don't describe what is your code made for, you will made a great sources but I don't know why?

cheers Paul




Added on : 14/08/02 by bram[ AT ]musicdsp[ DOT ]org
Comment :
hermite is interpollation.
have a look around the archive, you'll see that the word 'hermite' is in more than one item ;-)

  -bram




Added on : 29/07/03 by ronaldowf[ AT ]sanepar[ DOT ]com[ DOT ]br
Comment :
Please, would like to know of hermite code it exists in delphi.
  
thankful

Ronaldo
Cascavel/Paraná/Brasil




Added on : 10/10/03 by m[ DOT ]magrini[ AT ]NOSPAMbad-sector[ DOT ]com
Comment :
Please,
add, at least, the meaning of each parameter (I mean x, y0,  y1,y2,  y3)....
m.        




Added on : 28/11/03 by musicdsp[ AT ][remove this]dsparsons[ DOT ]co[ DOT ]uk
Comment :
Ronaldo, it doesn't take much to translate these to Delphi - for float, either use single or double to your preference!

Looking at the codes, it seems quite clear that the parameters follow a pattern of: Sample Position between middle two samples, then the sample before current, current sample, curernt sample +1, current sample +2.

HTH
DSP            




Added on : 28/03/04 by antiprosynthesis[ AT ]hotmail[ DOT ]com
Comment :
What are all these variables standing for? Not very clear :|



Added on : 19/04/04 by George
Comment :
parameters are allright.

xm1 ---> x[n-1]
x0  ---> x[n]
x1  ---> x[n+1]
x2  ---> x[n+2]

fractional position stands for a fraction between 0 and 1 to interpolate




Added on : 16/10/04 by paranoias-poison-door[ AT ]gmail[ DOT ]youknowwhatandtakeoutthehyphens
Comment :
Couldn't #2 be sped up a hair by commenting out

float c0 = y1;

and then replacing c0 with y1 in the return line?  Or do the compilers do that kind of thing automatically when they optimize?




Added on : 12/07/07 by asynth[ AT ]io[ DOT ]com
Comment :
"Couldn't #2 be sped up a hair"
It gets optimized out.




Add your own comment
Comments are displayed in fixed width, no HTML code allowed!
Email:

Comment:

Are you human?



Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion