date and time created 83/11/10 14:12:33 by ralph
[unix-history] / usr / src / lib / libplot / hp2648 / circle.c
CommitLineData
89996944
RC
1#ifndef lint
2static char sccsid[] = "@(#)circle.c 4.1 (Berkeley) %G%";
3#endif
4
5#include "hp2648.h"
6
7circle (xc,yc,r)
8int xc,yc,r;
9{
10 double costheta,sintheta,x,y,xn;
11 int xi,yi;
12
13 if(r<1){
14 point(xc,yc);
15 return;
16 }
17 sintheta = 1.0/r;
18 costheta = pow(1-sintheta*sintheta,0.5);
19 xi = x = r;
20 yi = y = 0;
21 do {
22 point(xc+xi,yc+yi);
23 xn = x;
24 xi = x = x*costheta + y*sintheta;
25 yi = y = y*costheta - xn*sintheta;
26 } while( ! (yi==0 && xi >= r-1));
27}