xref: /csrg-svn/lib/libplot/hp2648/circle.c (revision 61393)
148517Sbostic /*-
2*61393Sbostic  * Copyright (c) 1980, 1993
3*61393Sbostic  *	The Regents of the University of California.  All rights reserved.
448517Sbostic  *
548517Sbostic  * %sccs.include.proprietary.c%
619975Sdist  */
719975Sdist 
815446Sralph #ifndef lint
9*61393Sbostic static char sccsid[] = "@(#)circle.c	8.1 (Berkeley) 06/04/93";
1048517Sbostic #endif /* not lint */
1115446Sralph 
1215446Sralph #include "hp2648.h"
1315446Sralph 
circle(xc,yc,r)1415446Sralph circle (xc,yc,r)
1515446Sralph int xc,yc,r;
1615446Sralph {
1715446Sralph 	double costheta,sintheta,x,y,xn;
1815446Sralph 	int xi,yi;
1915446Sralph 
2015446Sralph 	if(r<1){
2115446Sralph 		point(xc,yc);
2215446Sralph 		return;
2315446Sralph 	}
2415446Sralph 	sintheta = 1.0/r;
2515446Sralph 	costheta = pow(1-sintheta*sintheta,0.5);
2615446Sralph 	xi = x = r;
2715446Sralph 	yi = y = 0;
2815446Sralph 	do {
2915446Sralph 		point(xc+xi,yc+yi);
3015446Sralph 		xn = x;
3115446Sralph 		xi = x = x*costheta + y*sintheta;
3215446Sralph 		yi = y = y*costheta - xn*sintheta;
3315446Sralph 	} while( ! (yi==0 && xi >= r-1));
3415446Sralph }
35