|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <math.h> ! 3: #include "tek.h" ! 4: /* arc plotting routine */ ! 5: /* from x1,y1 to x2,y2 */ ! 6: /* with center xc,yc and radius rr */ ! 7: /* integrates difference equation */ ! 8: /* negative rr draws counterclockwise */ ! 9: #define PI4 0.7854 ! 10: arc(x1, y1, x2, y2, xc, yc, rr) ! 11: double x1, x2, y1, y2, xc, yc, rr; ! 12: { ! 13: register double dx, dy, a, b; ! 14: double ph, dph, rd, xnext; ! 15: register int n; ! 16: dx = x1 - xc; ! 17: dy = y1 - yc; ! 18: rd = sqrt(dx * dx + dy * dy); ! 19: if (rd / e1->quantum < 1.0) { ! 20: move(xc, yc); ! 21: vec(xc, yc); ! 22: return(0); ! 23: } ! 24: dph = acos(1.0 - (e1->quantum / rd)); ! 25: if (dph > PI4) ! 26: dph = PI4; ! 27: ph=atan2((y2-yc),(x2 - xc)) - atan2(dy, dx); ! 28: if (ph < 0) ! 29: ph += 6.2832; ! 30: if (rr < 0) ! 31: ph = 6.2832 - ph; ! 32: if (ph < dph) ! 33: line(x1, y1, x2, y2); ! 34: else { ! 35: n = ph / dph; ! 36: a = cos(dph); ! 37: b = sin(dph); ! 38: if (rr < 0) ! 39: b = -b; ! 40: move(x1, y1); ! 41: while ((n--) >= 0) { ! 42: xnext = dx * a - dy * b; ! 43: dy = dx * b + dy * a; ! 44: dx = xnext; ! 45: vec(dx + xc, dy + yc); ! 46: } ! 47: } ! 48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.