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

Defined functions

quad defined in line 100; used 2 times
step defined in line 6; used 3 times

Defined variables

del defined in line 5; used 6 times
sccsid defined in line 2; never used
Last modified: 1987-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2185
Valid CSS Valid XHTML 1.0 Strict