source: trunk/FACT++/pal/palDrange.c@ 19547

Last change on this file since 19547 was 18347, checked in by tbretz, 9 years ago
File size: 1.9 KB
Line 
1/*
2*+
3* Name:
4* palDrange
5
6* Purpose:
7* Normalize angle into range +/- pi
8
9* Language:
10* Starlink ANSI C
11
12* Type of Module:
13* Library routine
14
15* Invocation:
16* palDrange( double angle )
17
18* Arguments:
19* angle = double (Given)
20* The angle in radians.
21
22* Description:
23* The result is "angle" expressed in the range +/- pi. If the
24* supplied value for "angle" is equal to +/- pi, it is returned
25* unchanged.
26
27* Authors:
28* DSB: David S Berry (JAC, Hawaii)
29* PTW: Patrick T. Wallace
30* {enter_new_authors_here}
31
32* History:
33* 2012-05-09 (DSB):
34* Initial version with documentation taken from Fortran SLA
35* Adapted with permission from the Fortran SLALIB library.
36* {enter_further_changes_here}
37
38* Copyright:
39* Copyright (C) 1995 Rutherford Appleton Laboratory
40* Copyright (C) 2012 Science and Technology Facilities Council.
41* All Rights Reserved.
42
43* Licence:
44* This program is free software: you can redistribute it and/or
45* modify it under the terms of the GNU Lesser General Public
46* License as published by the Free Software Foundation, either
47* version 3 of the License, or (at your option) any later
48* version.
49*
50* This program is distributed in the hope that it will be useful,
51* but WITHOUT ANY WARRANTY; without even the implied warranty of
52* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53* GNU Lesser General Public License for more details.
54*
55* You should have received a copy of the GNU Lesser General
56* License along with this program. If not, see
57* <http://www.gnu.org/licenses/>.
58
59* Bugs:
60* {note_any_bugs_here}
61*-
62*/
63
64#include "pal.h"
65#include "palmac.h"
66#include <math.h>
67
68double palDrange( double angle ){
69 double result = fmod( angle, PAL__D2PI );
70 if( result > PAL__DPI ) {
71 result -= PAL__D2PI;
72 } else if( result < -PAL__DPI ) {
73 result += PAL__D2PI;
74 }
75 return result;
76}
77
Note: See TracBrowser for help on using the repository browser.