--- ray/src/gen/sun.c 1992/10/02 16:12:29 2.2 +++ ray/src/gen/sun.c 2009/06/06 20:18:32 2.5 @@ -1,9 +1,6 @@ -/* Copyright (c) 1989 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: sun.c,v 2.5 2009/06/06 20:18:32 greg Exp $"; #endif - /* * SOLAR CALCULATIONS * @@ -13,7 +10,11 @@ static char SCCSid[] = "$SunId$ LBL"; #include -#define PI 3.141592654 +#ifdef M_PI +#define PI M_PI +#else +#define PI 3.141592653589793 +#endif double s_latitude = 0.66; /* site latitude (radians) */ double s_longitude = 2.13; /* site longitude (radians) */ @@ -21,8 +22,10 @@ double s_meridian = 2.0944; /* standard meridian (rad int -jdate(month, day) /* Julian date (days into year) */ -int month, day; +jdate( /* Julian date (days into year) */ + int month, + int day +) { static short mo_da[12] = {0,31,59,90,120,151,181,212,243,273,304,334}; @@ -31,8 +34,9 @@ int month, day; double -stadj(jd) /* solar time adjustment from Julian date */ -int jd; +stadj( /* solar time adjustment from Julian date */ + int jd +) { return( 0.170 * sin( (4*PI/373) * (jd - 80) ) - 0.129 * sin( (2*PI/355) * (jd - 8) ) + @@ -41,16 +45,19 @@ int jd; double -sdec(jd) /* solar declination angle from Julian date */ -int jd; +sdec( /* solar declination angle from Julian date */ + int jd +) { return( 0.4093 * sin( (2*PI/368) * (jd - 81) ) ); } double -salt(sd, st) /* solar altitude from solar declination and solar time */ -double sd, st; +salt( /* solar altitude from solar declination and solar time */ + double sd, + double st +) { return( asin( sin(s_latitude) * sin(sd) - cos(s_latitude) * cos(sd) * cos(st*(PI/12)) ) ); @@ -58,8 +65,10 @@ double sd, st; double -sazi(sd, st) /* solar azimuth from solar declination and solar time */ -double sd, st; +sazi( /* solar azimuth from solar declination and solar time */ + double sd, + double st +) { return( -atan2( cos(sd)*sin(st*(PI/12)), -cos(s_latitude)*sin(sd) -