ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/sun.c
Revision: 2.3
Committed: Sat Feb 22 02:07:24 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.2: +1 -4 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * SOLAR CALCULATIONS
6 *
7 * 3/31/87
8 *
9 */
10
11 #include <math.h>
12
13 #define PI 3.141592654
14
15 double s_latitude = 0.66; /* site latitude (radians) */
16 double s_longitude = 2.13; /* site longitude (radians) */
17 double s_meridian = 2.0944; /* standard meridian (radians) */
18
19
20 int
21 jdate(month, day) /* Julian date (days into year) */
22 int month, day;
23 {
24 static short mo_da[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
25
26 return(mo_da[month-1] + day);
27 }
28
29
30 double
31 stadj(jd) /* solar time adjustment from Julian date */
32 int jd;
33 {
34 return( 0.170 * sin( (4*PI/373) * (jd - 80) ) -
35 0.129 * sin( (2*PI/355) * (jd - 8) ) +
36 12 * (s_meridian - s_longitude) / PI );
37 }
38
39
40 double
41 sdec(jd) /* solar declination angle from Julian date */
42 int jd;
43 {
44 return( 0.4093 * sin( (2*PI/368) * (jd - 81) ) );
45 }
46
47
48 double
49 salt(sd, st) /* solar altitude from solar declination and solar time */
50 double sd, st;
51 {
52 return( asin( sin(s_latitude) * sin(sd) -
53 cos(s_latitude) * cos(sd) * cos(st*(PI/12)) ) );
54 }
55
56
57 double
58 sazi(sd, st) /* solar azimuth from solar declination and solar time */
59 double sd, st;
60 {
61 return( -atan2( cos(sd)*sin(st*(PI/12)),
62 -cos(s_latitude)*sin(sd) -
63 sin(s_latitude)*cos(sd)*cos(st*(PI/12)) ) );
64 }