In article <3h5hka$bq3@hpsystem1.informatik.tu-muenchen.de>, 
breitlip@Informatik.TU-Muenchen.DE says...
>
>
>I want to write fast interpolation routines that draw a curve through
>given Points. I heard of splines. But while i looked in some books it
>seems that they need 6 (!) MULS per point.
>

	No, you can evaluate them with forward differencing.

	A spline is just a parametric polynomial. You can evaluate any 
polynomial of degree N by using N deltas. Here is a function I wrote some 
time ago that draws a bezier curve segment with this technique. After the 
initial setup, you can see that it uses 6 adds per point. I have added a 
few more comments  to show how to make the code generally applicable. A 
full derivation can be found in Foley and van Dam, pp. 511-513. It looks 
nasty here but it's really very simple and uses only basic algebra.


/******Forward Difference Long Integer Bezier Draw*******/
/* Parameters are control point arrays, the number of   */
/* segments to draw, and the drawing color. Max 64      */
/* segments, because we're using integer arithmetic.    */
/********************************************************/
void BezierFwdDif(int mx[4],int my[4],int o,int color)
{
int i;
long int ax,bx,cx,ay,by,cy,n,n2,n3,px[4],py[4];
long int dx,dx2,dx3,dy,dy2,dy3,x,y;

//copy and shift up by 16 to get some fractional precision
for (i=0; i<4; i++)		
	{
	px[i]=((long)mx[i])<<16;
	py[i]=((long)my[i])<<16;
	}


//Calculate n=number of segments, and n^2, n^3
n=(long)(o=min(o,64)); n2=n*n; n3=n2*n;

//Setup the bexiaer curve coefficients. To draw other types of splines,
//just insert the righht coefficients here
ax=-px[0]+3*px[1]-3*px[2]+px[3];
ay=-py[0]+3*py[1]-3*py[2]+py[3];
bx=3*px[0]-6*px[1]+3*px[2];
by=3*py[0]-6*py[1]+3*py[2];
cx=-3*px[0]+3*px[1];
cy=-3*py[0]+3*py[1];

//Calculate deltas
x=px[0];
y=py[0];
dx=(ax/n3)+(bx/n2)+(cx/n);
dy=(ay/n3)+(by/n2)+(cy/n);
dx2=(6*ax/n3)+(2*bx/n2);		
dy2=(6*ay/n3)+2*by/n2;
dx3=6*ax/n3;
dy3=6*ay/n3;

setcolor(color);
moveto(x>>16,y>>16);

//Main loop, 6 adds per iteration
for (i=0; i<o; i++)
	{
	x+=dx; 		y+=dy;
	dx+=dx2;  	dy+=dy2;
	dx2+=dx3;	dy2+=dy3;
	lineto(x>>16,y>>16,color);
	}
}

-- 
_____________________________________________________________
\ shekter@hookup.net          \  Computer Science & Physics  \
 \ a228shek@cdf.toronto.edu    \    University Of Toronto     \
  \ jonathan@mcluhan.toronto.edu\ -> A Hacker Gets Physical <- \
   \_____________________________\______________________________\

