root / branches / v10 / libraries / libjni-proj4 / src / adjlon.c @ 27383
History | View | Annotate | Download (539 Bytes)
1 |
/* reduce argument to range +/- PI */
|
---|---|
2 |
#ifndef lint
|
3 |
static const char SCCSID[]="@(#)adjlon.c 4.3 93/06/12 GIE REL"; |
4 |
#endif
|
5 |
#include <math.h> |
6 |
#include <projects.h> |
7 |
|
8 |
#define SPI 3.14159265359 |
9 |
#define TWOPI 6.2831853071795864769 |
10 |
#define ONEPI 3.14159265358979323846 |
11 |
|
12 |
double adjlon (double lon) { |
13 |
if (fabs(lon) <= SPI) return( lon ); |
14 |
lon += ONEPI; /* adjust to 0..2pi rad */
|
15 |
lon -= TWOPI * floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
|
16 |
lon -= ONEPI; /* adjust back to -pi..pi rad */
|
17 |
return( lon );
|
18 |
} |