ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/sun.c
Revision: 2.2
Committed: Fri Oct 2 16:12:29 1992 UTC (31 years, 6 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +2 -8 lines
Log Message:
Removed problematic math function declarations

File Contents

# User Rev Content
1 greg 1.2 /* Copyright (c) 1989 Regents of the University of California */
2 greg 1.1
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6 greg 1.2
7     /*
8 greg 1.1 * SOLAR CALCULATIONS
9     *
10     * 3/31/87
11     *
12     */
13    
14 greg 2.2 #include <math.h>
15    
16 greg 1.1 #define PI 3.141592654
17    
18     double s_latitude = 0.66; /* site latitude (radians) */
19     double s_longitude = 2.13; /* site longitude (radians) */
20     double s_meridian = 2.0944; /* standard meridian (radians) */
21    
22    
23     int
24     jdate(month, day) /* Julian date (days into year) */
25     int month, day;
26     {
27     static short mo_da[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
28    
29     return(mo_da[month-1] + day);
30     }
31    
32    
33     double
34     stadj(jd) /* solar time adjustment from Julian date */
35     int jd;
36     {
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     sdec(jd) /* solar declination angle from Julian date */
45     int jd;
46     {
47     return( 0.4093 * sin( (2*PI/368) * (jd - 81) ) );
48     }
49    
50    
51     double
52     salt(sd, st) /* solar altitude from solar declination and solar time */
53     double sd, st;
54     {
55     return( asin( sin(s_latitude) * sin(sd) -
56     cos(s_latitude) * cos(sd) * cos(st*(PI/12)) ) );
57     }
58    
59    
60     double
61     sazi(sd, st) /* solar azimuth from solar declination and solar time */
62     double sd, st;
63     {
64     return( -atan2( cos(sd)*sin(st*(PI/12)),
65     -cos(s_latitude)*sin(sd) -
66     sin(s_latitude)*cos(sd)*cos(st*(PI/12)) ) );
67     }