int main( const int argc, const char **argv) { char buff[100]; FILE *ifile; time_t t0 = time( NULL); if( argc != 2) { printf( "'jsattest' needs a command-line argument from 1 to 4,\n"); printf( "corresponding to the number of the Galilean satellite\n"); printf( "that is being tested.\n"); return( -1); } sprintf( buff, "j%s.txt", argv[1]); ifile = fopen( buff, "rb"); if( !ifile) { printf( "%s not opened\n", buff); return( -1); } printf( "All data in kilometers, in J2000 ecliptic coords\n"); printf( "Compiled %s %s; run %s", __DATE__, __TIME__, ctime( &t0)); printf( " JDE dx dy dz "); printf( "x y z radial along\n"); while( fgets( buff, sizeof( buff), ifile)) if( strlen( buff) > 56 && !memcmp( buff + 37, "00:00:00.0000 (CT)", 18)) { const double jd = atof( buff ); double loc[15], *tptr = loc + atoi( argv[1]) * 3 - 3; double precess_matrix[9]; double j2000_loc[3], x, y, z, r; if( !fgets( buff, sizeof( buff), ifile)) { printf( "Read error"); return( -2); } x = atof( buff); y = atof( buff + 24); z = atof( buff + 47); setup_ecliptic_precession( precess_matrix, 2000. + (jd - 2451545.) / 365., 2000.); calc_jsat_loc( jd, loc, 15, 0L); precess_vector( precess_matrix, tptr, j2000_loc); j2000_loc[0] *= JRADIUS_IN_KM; j2000_loc[1] *= JRADIUS_IN_KM; j2000_loc[2] *= JRADIUS_IN_KM; j2000_loc[0] -= x; j2000_loc[1] -= y; j2000_loc[2] -= z; r = sqrt( x * x + y * y); printf( "%10.2f %10.3f%10.3f%10.3f %11.2f%11.2f%11.2f %10.2f %10.2f\n", jd, j2000_loc[0], j2000_loc[1], j2000_loc[2], x, y, z, (j2000_loc[0] * x + j2000_loc[1] * y) / r, (j2000_loc[1] * x - j2000_loc[0] * y) / r); } fclose( ifile); return( 0); }
int DLL_FUNC calc_ssat_loc( const double t, double DLLPTR *ssat, const int sat_wanted, const long precision) { SAT_ELEMS elems; ELEMENTS orbit; double matrix[9]; const double t_years = (t - J2000) / 365.25; if( precision == -1L) /* just checking version # */ return( 1); if( sat_wanted < 0 || sat_wanted > PHOEBE) return( -1); elems.jd = t; elems.sat_no = sat_wanted; set_ssat_elems( &elems, &orbit); setup_orbit_vectors( &orbit); comet_posn_part_ii( &orbit, IGNORED_DOUBLE, elems.loc, NULL); if( sat_wanted < RHEA) /* inner 4 satellites are returned in Saturnic */ { /* coords so gotta rotate to B1950.0 */ rotate_vector( elems.loc, INCL0, 0); rotate_vector( elems.loc, ASC_NODE0, 2); } /* After above, elems.loc is ecliptic 1950 coords */ rotate_vector( elems.loc, OBLIQUITY_1950, 0); /* Now, elems.loc is equatorial 1950 coords */ #ifdef OUTPUT_IN_J2000 setup_precession( matrix, 1950., 2000); precess_vector( matrix, elems.loc, ssat); /* Now, ssats is equatorial J2000... */ rotate_vector( ssat, -OBLIQUITY_2000, 0); /* And now, ssats is ecliptical J2000 */ #else setup_precession( matrix, 1950., 2000. + t_years); precess_vector( matrix, elems.loc, ssat); /* Now, ssats is equatorial of epoch coords */ rotate_vector( ssat, -mean_obliquity( t_years / 100.), 0); /* And now, ssats is ecliptical of epoch coords */ /* (which is what we really want anyway) */ #endif return( 0); }
void DLL_FUNC calc_triton_loc( const double jd, double *vect) { const double t_cent = (jd - J2000) / 36525.; const double n = (359.28 + 54.308 * t_cent) * (PI / 180.); const double t0 = 2433282.5; const double theta = (151.401 + .57806 * (jd - t0) / 365.25) * (PI / 180.); /* Semimajor axis is 488.49 arcseconds at one AU: */ const double semimajor = 488.49 * (PI / 180.) / 3600.; const double longitude = (200.913 + 61.2588532 * (jd - t0)) * (PI / 180.); const double gamma = 158.996 * (PI / 180.); /* Calculate longitude and latitude on invariable plane: */ const double lon_on_ip = theta + atan2( sin( longitude) * cos( gamma), cos( longitude)); const double lat_on_ip = asin( sin( longitude) * sin( gamma)); /* Vectors defining invariable plane, expressed in B1950: */ double x_axis[3], y_axis[3], z_axis[3]; /* Vector defining Triton position in invariable plane space: */ double triton[3]; /* RA/dec of the pole: */ double ra_dec_p[2]; double matrix[9]; double vect_1950[3]; int i; polar3_to_cartesian( triton, lon_on_ip, lat_on_ip); ra_dec_p[0] = (298.72 * PI / 180.) + (2.58 * PI / 180.) * sin( n) - (0.04 * PI / 180.) * sin( n + n); ra_dec_p[1] = (42.63 * PI / 180.) - (1.90 * PI / 180.) * cos( n) + (0.01 * PI / 180.) * cos( n + n); setup_precession( matrix, 1950., 2000.); precess_ra_dec( matrix, ra_dec_p, ra_dec_p, 1); polar3_to_cartesian( x_axis, ra_dec_p[0] + PI / 2., 0.); polar3_to_cartesian( y_axis, ra_dec_p[0] + PI, PI / 2. - ra_dec_p[1]); polar3_to_cartesian( z_axis, ra_dec_p[0], ra_dec_p[1]); for( i = 0; i < 3; i++) vect_1950[i] = semimajor * (x_axis[i] * triton[0] + y_axis[i] * triton[1] + z_axis[i] * triton[2]); precess_vector( matrix, vect_1950, vect); }