1*48517Sbostic /*- 2*48517Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*48517Sbostic * All rights reserved. 4*48517Sbostic * 5*48517Sbostic * %sccs.include.proprietary.c% 619975Sdist */ 719975Sdist 815445Sralph #ifndef lint 9*48517Sbostic static char sccsid[] = "@(#)arc.c 5.2 (Berkeley) 04/22/91"; 10*48517Sbostic #endif /* not lint */ 1115445Sralph 1215445Sralph #include "hp2648.h" 1315445Sralph 1415445Sralph arc(xcent,ycent,xbeg,ybeg,xend,yend) 1515445Sralph int xcent,ycent,xbeg,ybeg,xend,yend; 1615445Sralph { 1715445Sralph double costheta,sintheta,x,y,xn,r; 1815445Sralph double x1,y1,x2,y2; 1915445Sralph int xi,yi,crosspflag,crossp; 2015445Sralph 2115445Sralph r = (xcent-xbeg)*(xcent-xbeg)+(ycent-ybeg)*(ycent-ybeg); 2215445Sralph r = pow(r,0.5); 2315445Sralph if(r<1){ 2415445Sralph point(xcent,ycent); 2515445Sralph return; 2615445Sralph } 2715445Sralph sintheta = 1.0/r; 2815445Sralph costheta = pow(1-sintheta*sintheta,0.5); 2915445Sralph xi = x = xbeg-xcent; 3015445Sralph yi = y = ybeg-ycent; 3115445Sralph x1 = xcent; 3215445Sralph y1 = ycent; 3315445Sralph x2 = xend; 3415445Sralph y2 = yend; 3515445Sralph crosspflag = 0; 3615445Sralph do { 3715445Sralph crossp = cross_product(x1,y1,x2,y2,x,y); 3815445Sralph if(crossp >0 && crosspflag == 0) crosspflag = 1; 3915445Sralph point(xcent+xi,ycent+yi); 4015445Sralph xn = x; 4115445Sralph xi = x = x*costheta + y*sintheta; 4215445Sralph yi = y = y*costheta - xn*sintheta; 4315445Sralph } while( crosspflag == 0 || crossp >0); 4415445Sralph } 4515445Sralph 4615445Sralph cross_product(x1,y1,x2,y2,x3,y3) 4715445Sralph double x1,x2,x3,y1,y2,y3; 4815445Sralph { 4915445Sralph double z,a,b; 5015445Sralph a = (y3-y2)*(x2-x1); 5115445Sralph b = (x3-x2)*(y2-y1); 5215445Sralph z = a-b; 5315445Sralph if(z<0) return(-1); 5415445Sralph if(z>0) return(1); 5515445Sralph return(0); 5615445Sralph } 57