~ubuntu-branches/ubuntu/vivid/proj/vivid

« back to all changes in this revision

Viewing changes to src/adjlon.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter S Galbraith
  • Date: 2002-01-11 10:27:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020111102712-ayi18r8y2eesv0y9
Tags: upstream-4.4.5
ImportĀ upstreamĀ versionĀ 4.4.5

Show diffs side-by-side

added added

removed removed

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