#include #include #include "SpiceUsr.h" int main( int argc, char * argv[] ) { SpiceInt id; SpiceChar time[32]; SpiceDouble sungm; SpiceDouble state[6]; SpiceDouble et; SpiceDouble a; SpiceDouble lt; SpiceDouble elts[8]; /* Verify that command line contains exactly two arguments: asteroid number and Julian date of interest. */ if ( argc != 3 ) { printf ( "\nUsage: example [asteroid #] [JD]\n\n" ); return(1); } /* Load kernels: LSK, DE405 SPK, asteroid SPK and ECLIPJ2000_DE405 FK. */ furnsh_c( "naif0008.tls" ); furnsh_c( "de405.bsp" ); furnsh_c( "codes_300ast_20061020.bsp" ); furnsh_c( "eclipj2000_de405.tf" ); /* Set Sun GM to the DE405 value. */ sungm = 132712440017.987; /* Set NAIF of the asteroid (2000000 + asteroid number). */ prsint_c ( argv[1], &id ); printf( "%ld\n", id ); id = 2000000 + id; /* Set time in the form acceptable for str2et_c and convert it to TDB seconds part J2000. */ strcpy ( time, argv[2] ); strcat ( time, " TDB JD" ); str2et_c( time, &et ); /* Compute the geometric state of the asteroid relative to the Sun in ECLIPJ2000_DE405 frame, convert it to conic elements, and print them out in the same form as the CODES input. */ spkez_c ( id, et, "ECLIPJ2000_DE405", "NONE", 10, state, < ); oscelt_c( state, et, sungm, elts ); convrt_c( elts[0]/(1.0 - elts[1]), "KM", "AU", &a ); printf( "\n" ); printf( "Asteroid %ld relative to the Sun in ECLIPJ2000_DE405 frame:\n", id ); printf( "\n" ); printf( "a = %20.16e\n", a ); printf( "e = %20.16e\n", elts[1] ); printf( "i = %20.16e\n", elts[2] ); printf( "w = %20.16e\n", elts[4] ); printf( "omega = %20.16e\n", elts[3] ); printf( "M = %20.16e\n", elts[5] ); printf( "\n" ); /* Compute the geometric state of the asteroid relative to the Solar System Barycenter in the Earth Mean Equator and Equinox of J2000 ( named in SPICE J2000) frame and print it out. */ spkez_c ( id, et, "J2000", "NONE", 0, state, < ); printf( "\n" ); printf( "Asteroid %ld relative to the SSB in EME J2000 frame:\n", id ); printf( "\n" ); printf( "X = %20.16e\n", state[0] ); printf( "Y = %20.16e\n", state[1] ); printf( "Z = %20.16e\n", state[2] ); printf( "Vx = %20.16e\n", state[3] ); printf( "Vy = %20.16e\n", state[4] ); printf( "Vz = %20.16e\n", state[5] ); printf( "\n" ); return(0); }