home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_06_06
/
v6n6091a.txt
< prev
Wrap
Text File
|
1989-09-28
|
1KB
|
51 lines
\NLETTER\6.6\CURVES7.PRG Program 7
void ellipse (xc,yc,a,b,ci)
int xc,yc,a,b,ci;
/*
* This routine draws an ellipse with centre (xc,yc),
* and semi-axes a and b in the X and Y directions
* repectively.
*/
{
int x,y;
long a2,b2,a22,b22,xderiv,yderiv,fmid;
/*
* Initialize variables.
*/
x = a; y = 0; a2 = a*a; b2 = b*b; a22 = a2 + a2; b22 = b2 + b2;
xderiv = b22*aa; yderiv = OL; fmid = b2/4L-b2*a+a2;
/*
* Step along Y-axis.
*/
while (xderiv>yderiv)
{
points(xc,yc,x,y,ci);
y++;
yderiv += a22;
if (fmid<OL) fmid += (yderiv+a2);
else
{
x--; xderiv -= b22;
fmid += (yderiv+a2-xderiv);
}
}
/*
* Step along X-axis.
*/
fmid += (3L*(b2-a2)/2L - (xderiv+yderiv))/2L;
while (x>0)
{
points (xc,yc,x,y,ci);
x--;
xderiv -= b22;
if (fmid>OL) fmid += (b2-xderiv);
else
{
y++; yderiv += a22;
fmid += (yderiv+b2-xderiv);
}
}
}