From: Jay Link (jlink@interlink-bbs.com)
Date: Tue 30 Nov 1999 - 19:38:54 IST
Hi Everyone,
> hmmmm ... have you tested these routines with all possible radii ?
>
> without testing them myself, i suspect that there will be certain values
> for r (radius) that result in a less than perfectly filled circle or
> semi-circle. this being because of the rounding errors in the math
> functions and the line algorithm. nothing can be done about that except to
> be aware that these things happen :)
Ok, Ivan was right. If you draw a large circle with the function I posted,
you'll end up with some blank areas. BUT, the following "fix" accounts for
that. See what you think:
void filled_circle(int xc, int yc, int radius, int color)
{
double theta,
costheta,
sintheta;
int i,
y,
old_y = 0;
for (i = 0; i < 360; i++)
{
theta = (PI / 360) * i;
costheta = cos(theta);
sintheta = sin(theta);
y = yc + radius * costheta;
if (i > 0)
{
while ((old_y - y) > 1)
{
old_y--;
gl_hline(xc - radius * sintheta, old_y, xc + radius * sintheta, color);
}
}
gl_hline(xc - radius * sintheta, y, xc + radius * sintheta, color);
old_y = y;
}
}
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:22 IST