--- ray/src/gen/sun.c 1989/09/10 16:45:19 1.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 * @@ -11,16 +8,24 @@ static char SCCSid[] = "$SunId$ LBL"; * */ -#define PI 3.141592654 +#include +#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) */ double s_meridian = 2.0944; /* standard meridian (radians) */ 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}; @@ -29,11 +34,10 @@ int month, day; double -stadj(jd) /* solar time adjustment from Julian date */ -int jd; +stadj( /* solar time adjustment from Julian date */ + int jd +) { - double sin(); - return( 0.170 * sin( (4*PI/373) * (jd - 80) ) - 0.129 * sin( (2*PI/355) * (jd - 8) ) + 12 * (s_meridian - s_longitude) / PI ); @@ -41,32 +45,31 @@ int jd; double -sdec(jd) /* solar declination angle from Julian date */ -int jd; +sdec( /* solar declination angle from Julian date */ + int jd +) { - double sin(); - 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 +) { - double sin(), cos(), asin(); - return( asin( sin(s_latitude) * sin(sd) - cos(s_latitude) * cos(sd) * cos(st*(PI/12)) ) ); } 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 +) { - double sin(), cos(), atan2(); - return( -atan2( cos(sd)*sin(st*(PI/12)), -cos(s_latitude)*sin(sd) - sin(s_latitude)*cos(sd)*cos(st*(PI/12)) ) );