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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines