PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/Proj4/adjlon.c

http://github.com/route-me/route-me
C | 18 lines | 15 code | 2 blank | 1 comment | 1 complexity | 692d74d9d370e691d60d6b89d58c441f MD5 | raw file
 1/* reduce argument to range +/- PI */
 2#ifndef lint
 3static 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
12double 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}