ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/sun.c
Revision: 2.4
Committed: Sun Nov 16 10:29:38 2003 UTC (20 years, 5 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.3: +19 -11 lines
Log Message:
Continued ANSIfication and reduced other compile warnings.

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 schorsch 2.4 static const char RCSid[] = "$Id: sun.c,v 2.3 2003/02/22 02:07:24 greg Exp $";
3 greg 1.1 #endif
4 greg 1.2 /*
5 greg 1.1 * SOLAR CALCULATIONS
6     *
7     * 3/31/87
8     *
9     */
10    
11 greg 2.2 #include <math.h>
12    
13 greg 1.1 #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 schorsch 2.4 jdate( /* Julian date (days into year) */
22     int month,
23     int day
24     )
25 greg 1.1 {
26     static short mo_da[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
27    
28     return(mo_da[month-1] + day);
29     }
30    
31    
32     double
33 schorsch 2.4 stadj( /* solar time adjustment from Julian date */
34     int jd
35     )
36 greg 1.1 {
37     return( 0.170 * sin( (4*PI/373) * (jd - 80) ) -
38     0.129 * sin( (2*PI/355) * (jd - 8) ) +
39     12 * (s_meridian - s_longitude) / PI );
40     }
41    
42    
43     double
44 schorsch 2.4 sdec( /* solar declination angle from Julian date */
45     int jd
46     )
47 greg 1.1 {
48     return( 0.4093 * sin( (2*PI/368) * (jd - 81) ) );
49     }
50    
51    
52     double
53 schorsch 2.4 salt( /* solar altitude from solar declination and solar time */
54     double sd,
55     double st
56     )
57 greg 1.1 {
58     return( asin( sin(s_latitude) * sin(sd) -
59     cos(s_latitude) * cos(sd) * cos(st*(PI/12)) ) );
60     }
61    
62    
63     double
64 schorsch 2.4 sazi( /* solar azimuth from solar declination and solar time */
65     double sd,
66     double st
67     )
68 greg 1.1 {
69     return( -atan2( cos(sd)*sin(st*(PI/12)),
70     -cos(s_latitude)*sin(sd) -
71     sin(s_latitude)*cos(sd)*cos(st*(PI/12)) ) );
72     }