home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
AA_51.ZIP
/
TRNSIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-09
|
2KB
|
99 lines
/* Calculate time of transit
* assuming RA and Dec change uniformly with time
*
* -- S. L. Moshier
*/
#include "kep.h"
extern double glat;
/* Earth radii per au */
#define DISFAC 2.3454780e4
/* cosine of 90 degrees 50 minutes: */
#define COSSUN -0.014543897651582657
/* cosine of 90 degrees 34 minutes: */
#define COSZEN -9.8900378587411476e-3
int trnsit(J, lha, dec)
double J; /* Julian date */
double lha; /* local hour angle, radians */
double dec; /* declination, radians */
{
double x, y, z, N, D, TPI;
double lhay, cosdec, sindec, coslat, sinlat;
TPI = 2.0*PI;
/* observer's geodetic latitude, in radians */
x = glat * DTR;
coslat = cos(x);
sinlat = sin(x);
cosdec = cos(dec);
sindec = sin(dec);
x = (J - floor(J-0.5) - 0.5) * TPI;
/* adjust local hour angle */
y = lha;
while( y < -PI )
y += TPI;
while( y > PI )
y -= TPI;
lhay = y;
y = y/( -dradt/TPI + 1.00273790934);
N = x - y;
printf( "approx local meridian transit" );
hms( N );
printf( "UT (date + %.5lf)\n", N/TPI );
if( (coslat == 0.0) || (cosdec == 0.0) )
goto norise;
/* The time at which the upper limb of the body meets the
* horizon depends on the body's angular diameter.
*/
switch( objnum )
{
/* Sun */
case 0: N = COSSUN; break;
/* Moon, elevation = -34' - semidiameter + parallax
* semidiameter = 0.272453 * parallax + 0.0799"
*/
case 3:
N = 1.0/(DISFAC*obpolar[2]);
D = asin( N ); /* the parallax */
N = - 9.890199094634534e-3
+ (1.0 - 0.2725076)*D
- 3.874e-7;
N = sin(N);
break;
/* Other object */
default: N = COSZEN; break;
}
y = (N - sinlat*sindec)/(coslat*cosdec);
if( (y < 1.0) && (y > -1.0) )
{
/* Derivative of y with respect to declination
* times rate of change of declination:
*/
z = -ddecdt*(sinlat + COSZEN*sindec);
z /= TPI*coslat*cosdec*cosdec;
/* Derivative of acos(y): */
z /= sqrt( 1.0 - y*y);
y = acos(y);
printf( "rises approx " );
D = -dradt/TPI + 1.00273790934;
N = x - (lhay + y)*(1.0 + z)/D;
hms(N);
printf( "UT, sets approx " );
N = x - (lhay - y)*(1.0 - z)/D;
hms(N);
printf( "UT\n" );
}
norise: ;
return(0);
}