r99: *** empty log message ***
[ctsim.git] / libctsupport / normangle.cpp
1 /*****************************************************************************
2 **  This is part of the CTSim program
3 **  Copyright (C) 1983-2000 Kevin Rosenberg
4 **
5 **  $Id: normangle.cpp,v 1.1 2000/06/19 02:58:08 kevin Exp $
6 **
7 **  This program is free software; you can redistribute it and/or modify
8 **  it under the terms of the GNU General Public License (version 2) as
9 **  published by the Free Software Foundation.
10 **
11 **  This program is distributed in the hope that it will be useful,
12 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 **  GNU General Public License for more details.
15 **
16 **  You should have received a copy of the GNU General Public License
17 **  along with this program; if not, write to the Free Software
18 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 ******************************************************************************/
20
21 #include "kmath.h"
22
23
24 /* NAME
25  *    norm_ang                  Normalize angle to 0 to 2 * PI range
26  *
27  * SYNOPSIS
28  *    t = norm_ang (theta)
29  *    double t                  Normalized angle
30  *    double theta              Input angle
31  */
32
33 double 
34 norm_ang (double theta)
35 {
36   while (theta < 0.)
37     theta += TWOPI;
38   while (theta >= TWOPI)
39     theta -= TWOPI;
40   
41   return (theta);
42 }