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