1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: circle.cpp,v 1.2 2000/06/19 19:04:05 kevin Exp $
6 ** $Log: circle.cpp,v $
7 ** Revision 1.2 2000/06/19 19:04:05 kevin
8 ** reorganized header files
10 ** Revision 1.1 2000/06/19 18:05:03 kevin
13 ** Revision 1.1 2000/06/13 16:20:31 kevin
14 ** finished c++ conversions
16 ** Revision 1.2 2000/05/24 22:49:01 kevin
17 ** Updated SGP: first function X-windows version
19 ** Revision 1.1.1.1 2000/04/28 13:02:44 kevin
20 ** Initial CVS import for first public release
24 ** This program is free software; you can redistribute it and/or modify
25 ** it under the terms of the GNU General Public License (version 2) as
26 ** published by the Free Software Foundation.
28 ** This program is distributed in the hope that it will be useful,
29 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ** GNU General Public License for more details.
33 ** You should have received a copy of the GNU General Public License
34 ** along with this program; if not, write to the Free Software
35 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 ******************************************************************************/
39 * sgp2_circle - draw circle of radius r at current center
43 #include "ctsupport.h"
47 sgp2_draw_circle (const double r)
49 sgp2_draw_arc (0.0, 7.0, r);
52 /*==============================================================*/
53 /* draw arc around current center. pass angles and radius */
54 /*==============================================================*/
57 sgp2_draw_arc (double start, double stop, const double r)
59 double c, s, theta, angle;
62 if ((stop-start) > 2 * PI)
63 stop = start + 2 * PI;
64 if ((start-stop) > 2 * PI)
65 stop = start + 2 * PI;
69 x = r * cos ((double) start);
70 y = r * sin ((double) start);
71 sgp2_move_rel (x, y); /* move from center to start of arc */
77 for (angle = start; angle < stop - theta; angle += theta) {
80 sgp2_line_rel (xp - x, yp - y);
84 c = cos (stop - angle);
85 s = sin (stop - angle);
88 sgp2_line_rel (xp - x, yp - y);
90 x = r * cos ((double) stop);
91 y = r * sin ((double) stop);
92 sgp2_move_rel (-x, -y); /* move back to center of circle */