PageRenderTime 35ms CodeModel.GetById 29ms RepoModel.GetById 3ms app.codeStats 0ms

/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
  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. #define SPI 3.14159265359
  8. #define TWOPI 6.2831853071795864769
  9. #define ONEPI 3.14159265358979323846
  10. double adjlon (double lon) {
  11. if (fabs(lon) <= SPI) return( lon );
  12. lon += ONEPI; /* adjust to 0..2pi rad */
  13. lon -= TWOPI * floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
  14. lon -= ONEPI; /* adjust back to -pi..pi rad */
  15. return( lon );
  16. }