/[zanavi_public1]/navit/navit/sunriset.h
ZANavi

Contents of /navit/navit/sunriset.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (8 years, 2 months ago) by zoff99
File MIME type: text/plain
File size: 5033 byte(s)
import files
1 extern const char* timezone_name;
2 extern long int timezone_offset;
3
4 #define TMOD(x) ((x)<0?(x)+24:((x)>=24?(x)-24:(x)))
5 #define DAYSOFF(x) ((x)<0?"(-1) ":((x)>=24?"(+1) ":""))
6
7 #define HOURS(h) ((int)(floor(h)))
8 #define MINUTES(h) ((int)(60*(h-floor(h))))
9
10 #ifndef ABS
11 #define ABS(x) ((x)<0?-(x):(x))
12 #endif
13
14 /* A macro to compute the number of days elapsed since 2000 Jan 0.0 */
15 /* (which is equal to 1999 Dec 31, 0h UT) */
16 /* Dan R sez: This is some pretty fucking high magic. */
17 #define days_since_2000_Jan_0(y,m,d) \
18 (367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
19
20 /* Some conversion factors between radians and degrees */
21
22 #ifndef PI
23 #define PI 3.1415926535897932384
24 #endif
25
26 #define RADEG ( 180.0 / PI )
27 #define DEGRAD ( PI / 180.0 )
28
29 /* The trigonometric functions in degrees */
30
31 #define sind(x) sin((x)*DEGRAD)
32 #define cosd(x) cos((x)*DEGRAD)
33 #define tand(x) tan((x)*DEGRAD)
34
35 #define atand(x) (RADEG*atan(x))
36 #define asind(x) (RADEG*asin(x))
37 #define acosd(x) (RADEG*acos(x))
38 #define atan2d(y,x) (RADEG*atan2(y,x))
39
40 /* Following are some macros around the "workhorse" function __daylen__ */
41 /* They mainly fill in the desired values for the reference altitude */
42 /* below the horizon, and also selects whether this altitude should */
43 /* refer to the Sun's center or its upper limb. */
44
45
46 /* This macro computes the length of the day, from sunrise to sunset. */
47 /* Sunrise/set is considered to occur when the Sun's upper limb is */
48 /* 50 arc minutes below the horizon (this accounts for the refraction */
49 /* of the Earth's atmosphere). */
50 /* The original version of the program used the value of 35 arc mins, */
51 /* which is the accepted value in Sweden. */
52 #define day_length(year,month,day,lon,lat) \
53 __daylen__( year, month, day, lon, lat, -50.0/60.0, 1 )
54
55 /* This macro computes the length of the day, including civil twilight. */
56 /* Civil twilight starts/ends when the Sun's center is 6 degrees below */
57 /* the horizon. */
58 #define day_civil_twilight_length(year,month,day,lon,lat) \
59 __daylen__( year, month, day, lon, lat, -6.0, 0 )
60
61 /* This macro computes the length of the day, incl. nautical twilight. */
62 /* Nautical twilight starts/ends when the Sun's center is 12 degrees */
63 /* below the horizon. */
64 #define day_nautical_twilight_length(year,month,day,lon,lat) \
65 __daylen__( year, month, day, lon, lat, -12.0, 0 )
66
67 /* This macro computes the length of the day, incl. astronomical twilight. */
68 /* Astronomical twilight starts/ends when the Sun's center is 18 degrees */
69 /* below the horizon. */
70 #define day_astronomical_twilight_length(year,month,day,lon,lat) \
71 __daylen__( year, month, day, lon, lat, -18.0, 0 )
72
73
74 /* This macro computes times for sunrise/sunset. */
75 /* Sunrise/set is considered to occur when the Sun's upper limb is */
76 /* 35 arc minutes below the horizon (this accounts for the refraction */
77 /* of the Earth's atmosphere). */
78 #define sun_rise_set(year,month,day,lon,lat,rise,set) \
79 __sunriset__( year, month, day, lon, lat, -35.0/60.0, 1, rise, set )
80
81 /* This macro computes the start and end times of civil twilight. */
82 /* Civil twilight starts/ends when the Sun's center is 6 degrees below */
83 /* the horizon. */
84 #define civil_twilight(year,month,day,lon,lat,start,end) \
85 __sunriset__( year, month, day, lon, lat, -6.0, 0, start, end )
86
87 /* This macro computes the start and end times of nautical twilight. */
88 /* Nautical twilight starts/ends when the Sun's center is 12 degrees */
89 /* below the horizon. */
90 #define nautical_twilight(year,month,day,lon,lat,start,end) \
91 __sunriset__( year, month, day, lon, lat, -12.0, 0, start, end )
92
93 /* This macro computes the start and end times of astronomical twilight. */
94 /* Astronomical twilight starts/ends when the Sun's center is 18 degrees */
95 /* below the horizon. */
96 #define astronomical_twilight(year,month,day,lon,lat,start,end) \
97 __sunriset__( year, month, day, lon, lat, -18.0, 0, start, end )
98
99
100 /* Function prototypes */
101
102 double __daylen__( int year, int month, int day, double lon, double lat,
103 double altit, int upper_limb );
104
105 int __sunriset__( int year, int month, int day, double lon, double lat,
106 double altit, int upper_limb, double *rise, double *set );
107
108 void sunpos( double d, double *lon, double *r );
109
110 void sun_RA_dec( double d, double *RA, double *dec, double *r );
111
112 double revolution( double x );
113
114 double rev180( double x );
115
116 double GMST0( double d );
117

   
Visit the ZANavi Wiki