import jephem.astro.AstroContext;
import jephem.astro.Body;
import jephem.astro.SolarSystemConstants;
import jephem.astro.SolarSystem;
import jephem.astro.spacetime.SpaceConstants;
import jephem.astro.spacetime.UnitConstants;
public class testJEphem implements SolarSystemConstants, UnitConstants, SpaceConstants{
public static void main(String[] args){
// Build the AstroContext
int[] bodyIndexes = {SUN, MOON, MERCURY, VENUS, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO};
double jd = 245897.52;
AstroContext ac = new AstroContext(jd, bodyIndexes);
// Prepare the variables
int frame = GEOCENTRIC_ECLIPTIC;
int sphereCart = SPHERICAL;
double precision = 1.0;
int[] units = {DISTANCE_UNIT_AU, ANGULAR_UNIT_DEG, ANGULAR_UNIT_DEG,
LINEAR_SPEED_UNIT_AU_PER_D, ANGULAR_SPEED_UNIT_DEG_PER_DAY, ANGULAR_SPEED_UNIT_DEG_PER_DAY};
boolean velocities = true;
// order the computation
ac.calcBodyCoord(frame,
sphereCart,
precision,
velocities,
units);
// Display the coordinates
Body[] bodies = ac.getBodies();
Body curBody;
int coordGroup = Space.getCoordGroup(frame, sphereCart);
String[] coordLabels = Space.getCoordLabels(coordGroup);
int[] units;
for(int i = 0; i < bodies.length; i++){
curBody = bodies[i];
System.out.println(curBody.getName() + " : ");
units = curBody.getPositionUnits();
for(j = 0; j < 3; j++){
System.out.println(" " + coordLabels[j] + " : " + curBody.getCoord(j) + " " + Units.getUnitLabel(units[j]));
}
if(velocities){
units = curBody.getVelocityUnits();
for(int j = 0; j < 3; j++){
System.out.println(" d(" + coordLabels[j] + ")/dt : " + curBody.getCoord(j+3) + " " + Units.getUnitLabel(units[j]));
}
}
}// end for i
}// end main()
}// end class
|