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.2 by greg, Sun Sep 10 16:45:19 1989 UTC vs.
Revision 2.4 by schorsch, Sun Nov 16 10:29:38 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines