Archived

This topic is now archived and is closed to further replies.

laeuchli

cubic interpolation.

Recommended Posts

laeuchli    338
I have a cubic interpolation function here: float splineinterp(float number1,float afternumber1, float number2, float afternumber2,float x) { float P=(afternumber2-number2)-(number1-afternumber1); float Q=(number1-afternumber1)-P; float R=(number2-number1); float S=afternumber1; float ret=P*(x*x*x)+Q*(x*x)+(R*x)+S; return ret; } before I was using cosine interpolation, and doing this: int xi=x; float fractionx=x-xi; int yi=y; float fractiony=y-yi; float v1,v2,v3,v4,i1,i2; float ret; v1=smoothnoise(xi, yi); v2=smoothnoise(xi + 1, yi); v3=smoothnoise(xi, yi + 1); v4=smoothnoise(xi + 1, yi + 1); i1=cosinterp(v1,v2,fractiony); i2=cosinterp(v3,v4,fractionx); ret=cosinterp(i1,i2,fractiony); How can I change and use cubic interpolation? My main problem is figuring out what to use for X.

Share this post


Link to post
Share on other sites