ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/sun.c
(Generate patch)

Comparing ray/src/gen/sun.c (file contents):
Revision 1.1 by greg, Thu Feb 2 11:16:32 1989 UTC vs.
Revision 2.5 by greg, Sat Jun 6 20:18:32 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines