ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/lib4014/arc.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     #ifndef lint
5     static char sccsid[] = "@(#)arc.c 4.1 (Berkeley) 6/27/83";
6     #endif
7    
8     int del = 20;
9     step(d){
10     del = d;
11     }
12     arc(x,y,x0,y0,x1,y1){
13     double pc;
14     double sqrt();
15     int flg,m,xc,yc,xs,ys,qs,qf;
16     float dx,dy,r;
17     char use;
18     dx = x-x0;
19     dy = y-y0;
20     r = dx*dx+dy*dy;
21     pc = r;
22     pc = sqrt(pc);
23     flg = pc/4;
24     if(flg == 0)step(1);
25     else if(flg < del)step(flg);
26     xc = xs = x0;
27     yc = ys = y0;
28     move(xs,ys);
29     if(x0 == x1 && y0 == y1)flg=0;
30     else flg=1;
31     qs = quad(x,y,x0,y0);
32     qf = quad(x,y,x1,y1);
33     if(abs(x-x1) < abs(y-y1)){
34     use = 'x';
35     if(qs == 2 || qs ==3)m = -1;
36     else m=1;
37     }
38     else {
39     use = 'y';
40     if(qs > 2)m= -1;
41     else m= 1;
42     }
43     while(1){
44     switch(use){
45     case 'x':
46     if(qs == 2 || qs == 3)yc -= del;
47     else yc += del;
48     dy = yc-y;
49     pc = r-dy*dy;
50     xc = m*sqrt(pc)+x;
51     if((x < xs && x >= xc) || ( x > xs && x <= xc) ||
52     (y < ys && y >= yc) || ( y > ys && y <= yc) )
53     {
54     if(++qs > 4)qs=1;
55     if(qs == 2 || qs == 3)m= -1;
56     else m=1;
57     flg=1;
58     }
59     cont(xc,yc);
60     xs = xc;
61     ys = yc;
62     if(qs == qf && flg == 1)
63     switch(qf){
64     case 3:
65     case 4:
66     if(xs >= x1)return;
67     continue;
68     case 1:
69     case 2:
70     if(xs <= x1)return;
71     }
72     continue;
73     case 'y':
74     if(qs > 2)xc += del;
75     else xc -= del;
76     dx = xc-x;
77     pc = r-dx*dx;
78     yc = m*sqrt(pc)+y;
79     if((x < xs && x >= xc) || ( x > xs && x <= xc ) ||
80     (y < ys && y >= yc) || (y > ys && y <= yc) )
81     {
82     if(++qs > 4)qs=1;
83     if(qs > 2)m = -1;
84     else m = 1;
85     flg=1;
86     }
87     cont(xc,yc);
88     xs = xc;
89     ys = yc;
90     if(qs == qf && flg == 1)
91     switch(qs){
92     case 1:
93     case 4:
94     if(ys >= y1)return;
95     continue;
96     case 2:
97     case 3:
98     if(ys <= y1)return;
99     }
100     }
101     }
102     }
103     quad(x,y,xp,yp){
104     if(x < xp)
105     if(y <= yp)return(1);
106     else return(4);
107     else if(x > xp)
108     if(y < yp)return(2);
109     else return(3);
110     else if(y < yp)return(2);
111     else return(4);
112     }
113     abs(a){
114     if(a < 0)return(-a);
115     return(a);
116     }