Article View: comp.lang.postscript
Article #1614Re: Evaluation of Splines
From: Woodrow Baker
Date: Tue, 23 Jan 1990 23:28
Date: Tue, 23 Jan 1990 23:28
76 lines
2254 bytes
2254 bytes
I recently had a conversation with a very mathematically oriented freind in
California, in which he mentioned that it would be possible to evaluate a
Bezier spline with *NO* multiplies using a "diffrence table"
Can anyone shed some light on exactly what he is talking about, and point
me to some reasonably clear explaination of how to accomplish the
computation of the table? I currently have a very simple minded Bexier
drawing routine, written in 'C' that I'n not altogether happy with. I've
distilled it down to 3 multiplies, but would like to get rid of them.
code follows:
/*
compute the coefficents for the 3rd order
cubic parametric equations that make up a Bezier
cubic spline
*/
computcof()
{
xd=x[1]-x[2]; /* factor out common expressions for */
yd=y[1]-y[2]; /* more speed and effeciency */
xd1=3*x[0];
yd1=3*y[0];
coeff[ax]=3*xd+x[3]-x[0];
coeff[ay]=3*yd+y[3]-y[0];
coeff[bx]=-3*(x[1]+xd)+xd1;
coeff[by]=-3*(y[1]+yd)+yd1;
coeff[cx]=3*(x[1]-x[0]);
coeff[cy]=3*(y[1]-y[0]);
}
/*
sets up and draws the spline. f is a flag that
determines whether to erase or draw the spline
*/
dospline(x0,y0,x1,y1,x2,y2,x3,y3,f)
int x0,y0,x1,y1,x2,y2,x3,y3,f;
{
x[0]=x0;
y[0]=y0;
x[1]=x1;
y[1]=y1;
x[2]=x2;
y[2]=y2;
x[3]=x3;
y[3]=y3;
computcof();
drawspline(f);
}
/*
draws splines
*/
drawspline(f)
int f;
{
float t;
int x1,y1,p;
for (t=0;t<1;t=t+.01)
{
x1=(((coeff[ax]*t)+coeff[bx])*t+coeff[cx])*t+x[0];
y1=(((coeff[ay]*t)+coeff[by])*t+coeff[cy])*t+y[0];
if(f==0)
{
SETPIX(x1,y1,1,0); /* put dot down */
}
else
{
SETPIX(x1,y1,1,3); /* erase dot */
}
};
}
I'm sure that this can be speeded up dramatically, if the multiplies
in drawspline can be removed, and the entire thing can be integerized.
Any help would be appreciated:
Cheers
Woody
Technical Details
Message-ID:
<17739@rpp386.cactus.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!natinst!rpp386!woodyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!natinst!rpp386!woody From: woody@rpp386.cactus.org (Woodrow Baker) Newsgroups: comp.lang.postscript Subject: Re: Evaluation of Splines Summary: evaluating splines Message-ID: <17739@rpp386.cactus.org> Date: 23 Jan 90 23:28:29 GMT Organization: River Parishes Programming, Plano, TX Lines: 76