home *** CD-ROM | disk | FTP | other *** search
-
- /************************************************************************/
- /* Brute force arc generation */
- /************************************************************************/
-
- brute_arc(xc,yc,xp,yp,a0,a1,color)
- int xc,yc; /* Center of the arc */
- int xp,yp; /* Any point on full circle */
- int a0,a1; /* Starting and ending angle in degrees */
- int color; /* Color of the arc */
- {
- #include <math.h>
- #define PI 3.1415926
- float a,b,f,dx,dy;
- int xa,ya,xb,yb,alpha,delta;
-
- if (xp - xc == 0 && yp - yc == 0)/* Process degenerate case */
- {
- pixel_write(xc,yc,color);
- return;
- }
- /* Compute major & minor axis */
- if (get_scanlines() > 200) f = 480./350.;
- else f = 480./200.;
- dx= xp - xc;
- dy=(yp - yc)*f;
- a = sqrt(dx * dx + dy * dy);
- b = a/f;
- /* Compute first point */
- xa = xc + a * cos((double)(a0 * PI/180.));
- ya = yc + b * sin((double)(a0 * PI/180.));
- delta = 6 * 180./(PI * a); /* Force 6 pixels per segment */
- /* Loop over segment on ellipse */
- for (alpha = a0; alpha <= a1; alpha = alpha + delta)
- { /* Compute next point on ellipse*/
- xb = xc + a * cos(alpha * PI/180.);
- yb = yc + b * sin(alpha * PI/180.);
- line (xa, ya, xb, yb, color); /* Draw to previous pt */
- xa = xb;
- ya = yb;
- }
- /* Do the last segment */
- xb = xc + a * cos(a1 * PI/180.);
- yb = yc + b * sin(a1 * PI/180.);
- line (xa, ya, xb, yb, color);
- }