static void linear_arc(int x0, int y0, int radius, double theta, double delta_theta) /* x coordinate of center */ /* y coordinate of center */ /* radius of arc */ /* initial angle ( +x axis = 0 rad ) */ /* delta angle */ /* * Notes: * Draws an arc of radius and center at (x0,y0) beginning at * angle theta (in rad) and ending at theta + delta_theta */ { int x1, y1, x2, y2; int i, s = 60; double dphi; x2 = x0 + (int) (radius * cos(theta)); y2 = y0 + (int) (radius * sin(theta)); dphi = delta_theta / s; for (i = 1; i <= s; i++) { x1 = x2; y1 = y2; x2 = x0 + (int)(radius * cos(theta + i*dphi)); y2 = y0 + (int)(radius * sin(theta + i*dphi)); X11_DrawLine(x1, y1, x2, y2); } }
static void linear_arc(int x0, int y0, int radius, double theta1, double theta2) /* x coordinate of center */ /* y coordinate of center */ /* radius of arc */ /* initial angle ( +x axis = 0 rad ) */ /* final angle ( +x axis = 0 rad ) */ /* * Notes: * Draws an arc of radius and center at (x0,y0) beginning at * angle theta1 (in rad) and ending at theta2 */ { int x1, y1, x2, y2; int s = 60; double dphi, phi; x2 = x0 + (int) (radius * cos(theta1)); y2 = y0 + (int) (radius * sin(theta1)); while(theta1 >= theta2) theta2 += 2 * M_PI; dphi = (theta2 - theta1) / s; if ((theta1 + dphi) == theta1) { theta2 += 2 * M_PI; dphi = (theta2 - theta1) / s; } for(phi = theta1 + dphi; phi < theta2; phi += dphi) { x1 = x2; y1 = y2; x2 = x0 + (int)(radius * cos(phi)); y2 = y0 + (int)(radius * sin(phi)); X11_DrawLine(x1,y1,x2,y2); } x1 = x2; y1 = y2; x2 = x0 + (int)(radius * cos(theta2)); y2 = y0 + (int)(radius * sin(theta2)); X11_DrawLine(x1,y1,x2,y2); }