Add copyright notice
[unix-history] / usr / src / lib / libplot / hp2648 / circle.c
CommitLineData
dca25f5a
DF
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
89996944 7#ifndef lint
dca25f5a
DF
8static char sccsid[] = "@(#)circle.c 5.1 (Berkeley) %G%";
9#endif not lint
89996944
RC
10
11#include "hp2648.h"
12
13circle (xc,yc,r)
14int 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}