| 1 | /* |
| 2 | * Copyright (c) 1980 Regents of the University of California. |
| 3 | * All rights reserved. The Berkeley software License Agreement |
| 4 | * specifies the terms and conditions for redistribution. |
| 5 | */ |
| 6 | |
| 7 | #ifndef lint |
| 8 | static char sccsid[] = "@(#)circle.c 5.1 (Berkeley) %G%"; |
| 9 | #endif not lint |
| 10 | |
| 11 | #include "hp2648.h" |
| 12 | |
| 13 | circle (xc,yc,r) |
| 14 | int xc,yc,r; |
| 15 | { |
| 16 | double costheta,sintheta,x,y,xn; |
| 17 | int xi,yi; |
| 18 | |
| 19 | if(r<1){ |
| 20 | point(xc,yc); |
| 21 | return; |
| 22 | } |
| 23 | sintheta = 1.0/r; |
| 24 | costheta = pow(1-sintheta*sintheta,0.5); |
| 25 | xi = x = r; |
| 26 | yi = y = 0; |
| 27 | do { |
| 28 | point(xc+xi,yc+yi); |
| 29 | xn = x; |
| 30 | xi = x = x*costheta + y*sintheta; |
| 31 | yi = y = y*costheta - xn*sintheta; |
| 32 | } while( ! (yi==0 && xi >= r-1)); |
| 33 | } |