160 CEBody(name, xcoord, ycoord, coord_type)
196 if (
this != &other) {
214 CEPlanet mercury(
"Mercury", 0.0, 0.0) ;
215 mercury.SetSemiMajorAxis_AU(0.38709843, 0.0) ;
216 mercury.SetEccentricity(0.20563661, 0.00002123) ;
223 mercury.SetMeanRadius_m(2440000.0) ;
224 mercury.SetAlbedo(0.106) ;
225 mercury.SetMass_kg(3.302E23) ;
228 mercury.SetSofaID(1) ;
240 venus.SetSemiMajorAxis_AU(0.72332102, -0.00000026) ;
241 venus.SetEccentricity(0.00676399, -0.00005107) ;
248 venus.SetMeanRadius_m(6051800.0) ;
249 venus.SetAlbedo(0.65) ;
250 venus.SetMass_kg(48.685E23) ;
265 earth.SetSemiMajorAxis_AU(1.00000018, -0.00000003) ;
266 earth.SetEccentricity(0.01673163, -0.00003661) ;
273 earth.SetMeanRadius_m(0.0) ;
274 earth.SetAlbedo(0.0) ;
275 earth.SetMass_kg(0.0) ;
278 earth.SetSofaID(3.5) ;
290 CEPlanet em_barycenter(
"EMBaryCenter", 0.0, 0.0) ;
291 em_barycenter.SetSemiMajorAxis_AU(1.00000018, -0.00000003) ;
292 em_barycenter.SetEccentricity(0.01673163, -0.00003661) ;
299 em_barycenter.SetSofaID(3) ;
301 return em_barycenter ;
312 mars.SetSemiMajorAxis_AU(1.52371243, 0.00000097) ;
313 mars.SetEccentricity(0.09336511, 0.00009149) ;
320 mars.SetMeanRadius_m(3389900.0) ;
321 mars.SetAlbedo(0.150) ;
322 mars.SetMass_kg(6.4185E23) ;
338 CEPlanet jupiter(
"Jupiter", 0.0, 0.0) ;
339 jupiter.SetSemiMajorAxis_AU(5.20248019, -0.00002864) ;
340 jupiter.SetEccentricity(0.04853590, -0.00005107) ;
346 jupiter.SetExtraTerms(-0.00012452, 0.06064060, -0.35635438, 38.35125000) ;
349 jupiter.SetMeanRadius_m(69911000.0) ;
350 jupiter.SetAlbedo(0.52) ;
351 jupiter.SetMass_kg(1.89813E27) ;
354 jupiter.SetSofaID(5) ;
366 CEPlanet saturn(
"Saturn", 0.0, 0.0) ;
367 saturn.SetSemiMajorAxis_AU(9.54149883, -0.00003065) ;
368 saturn.SetEccentricity(0.05550825, -0.00032044) ;
374 saturn.SetExtraTerms(0.00025899, -0.13434469, 0.87320147, 38.35125000) ;
377 saturn.SetMeanRadius_m(58232000.0) ;
378 saturn.SetAlbedo(0.47) ;
379 saturn.SetMass_kg(5.68319E26) ;
382 saturn.SetSofaID(6) ;
394 CEPlanet uranus(
"Uranus", 0.0, 0.0) ;
395 uranus.SetSemiMajorAxis_AU(19.18797948, -0.00020455) ;
396 uranus.SetEccentricity(0.04685740, -0.00001550) ;
402 uranus.SetExtraTerms(0.00058331, -0.97731848, 0.17689245, 7.67025000) ;
405 uranus.SetMeanRadius_m(25362000.0) ;
406 uranus.SetAlbedo(0.51) ;
407 uranus.SetMass_kg(8.68103E25) ;
410 uranus.SetSofaID(7) ;
422 CEPlanet neptune(
"Neptune", 0.0, 0.0) ;
423 neptune.SetSemiMajorAxis_AU(30.06952752, 0.00006447) ;
424 neptune.SetEccentricity(0.00895439, 0.00000818) ;
430 neptune.SetExtraTerms(-0.00041348, 0.68346318, -0.10162547, 7.67025000) ;
433 neptune.SetMeanRadius_m(24624000.0) ;
434 neptune.SetAlbedo(0.41) ;
435 neptune.SetMass_kg(1.0241E26) ;
438 neptune.SetSofaID(8) ;
452 pluto.SetSemiMajorAxis_AU(39.48686035, 0.00449751) ;
453 pluto.SetEccentricity(0.24885238, 0.00006016) ;
459 pluto.SetExtraTerms(-0.01262724, 0.0, 0.0, 0.0) ;
462 pluto.SetMeanRadius_m(1195000.0) ;
463 pluto.SetAlbedo(0.3) ;
464 pluto.SetMass_kg(1.307E22) ;
481 double semi_major_axis_au_per_cent)
484 if (semi_major_axis_au <= 0.0) {
485 std::cerr <<
"[ERROR] CEPlanet::SetSemiMajorAxis_AU() : Semi major axis must be positive!\n";
487 semi_major_axis_au_ = semi_major_axis_au ;
488 semi_major_axis_au_per_cent_ = semi_major_axis_au_per_cent ;
499 double eccentricity_per_cent)
501 eccentricity_ = eccentricity ;
502 eccentricity_per_cent_ = eccentricity_per_cent ;
513 double inclination_per_cent,
517 inclination *= DR2D ;
518 inclination_per_cent *= DR2D ;
521 inclination_deg_ = inclination ;
522 inclination_deg_per_cent_ = inclination_per_cent * DR2D ;
533 double mean_longitude_per_cent,
537 mean_longitude *= DR2D ;
538 mean_longitude_per_cent *= DR2D ;
541 mean_longitude_deg_ = mean_longitude ;
542 mean_longitude_deg_per_cent_ = mean_longitude_per_cent ;
553 double perihelion_lon_per_cent,
557 perihelion_lon *= DR2D ;
558 perihelion_lon_per_cent *= DR2D ;
561 perihelion_lon_deg_ = perihelion_lon ;
562 perihelion_long_deg_per_cent_ = perihelion_lon_per_cent ;
573 double ascending_node_lon_per_cent,
577 ascending_node_lon *= DR2D ;
578 ascending_node_lon_per_cent *= DR2D ;
581 ascending_node_lon_deg_ = ascending_node_lon ;
582 ascending_node_lon_deg_per_cent_ = ascending_node_lon_per_cent ;
600 std::vector<double> pos = pos_icrs_;
601 double x = pos[0] - earth.
GetXICRS();
602 double y = pos[1] - earth.
GetYICRS();
603 double z = pos[2] - earth.
GetZICRS();
606 return std::sqrt(x*x + y*y + z*z);
621 past.UpdatePosition(date);
624 double earth_dist = past.EarthDist_AU(date);
628 past.UpdatePosition(date.
JD() - delay);
629 return past.PositionICRS();
644 UpdatePosition(date);
648 std::vector<double> offset = observer.
PositionICRS(date);
649 std::vector<double> pos_obs = PositionICRS_Obs(date);
652 for (
int i=0; i<3; i++)
653 offset[i] = pos_obs[i] - offset[i];
658 iauC2s(&offset[0], &ra, &dec);
662 if (sofa_planet_id_ == 3.5) {
681 if ((new_jd < -1.0e29) || (new_jd == cached_jd_))
return;
684 UpdatePosition(new_jd);
687 std::vector<double> pos_delayed = PositionICRS_Obs(date);
692 iauC2s(&pos_delayed[0], &x, &y);
701 cached_jd_ = new_jd ;
712 if ((jd < -1.0e29) || (jd == cached_jd_)) {
740 int err = iauEpv00(tdb1, tdb2, pvhe, pvb);
743 if (sofa_planet_id_ != 3.5) {
745 err = iauPlan94(tdb1, tdb2, sofa_planet_id_, pvh) ;
749 for (
int i=0; i<2; i++) {
750 for (
int j=0; j<3; j++) {
751 pvb[i][j] = pvh[i][j] + (pvb[i][j] - pvhe[i][j]);
759 pos_icrs_ = std::vector<double>(pvb[0], pvb[0]+3);
762 vel_icrs_ = std::vector<double>(pvb[1], pvb[1]+3);
764 std::cerr <<
"[ERROR] failed to compute planet positions for " << Name() <<
". ErrCode=" << err <<
"\n" ;
786 double a = ComputeElement(semi_major_axis_au_, semi_major_axis_au_per_cent_, T) ;
787 double e = ComputeElement(eccentricity_, eccentricity_per_cent_, T) ;
788 double I = ComputeElement(inclination_deg_, inclination_deg_per_cent_, T) ;
789 double L = ComputeElement(mean_longitude_deg_, mean_longitude_deg_per_cent_, T) ;
790 double w = ComputeElement(perihelion_lon_deg_, perihelion_long_deg_per_cent_, T) ;
791 double O = ComputeElement(ascending_node_lon_deg_, ascending_node_lon_deg_per_cent_, T) ;
795 double M = MeanAnomaly(L, w, T) ;
798 double E = M + e*DR2D * std::sin(M*DD2R) ;
800 E = EccentricAnomoly(M, e, E, del_E) ;
803 double x_prime = a * (std::cos(E*DD2R) - e) ;
804 double y_prime = a * std::sqrt(1.0 - (e*e)) * std::sin(E*DD2R) ;
808 double x_ecl = x_prime * (std::cos(W*DD2R)*std::cos(O*DD2R) - std::sin(W*DD2R)*std::sin(O*DD2R)*std::cos(I*DD2R)) +
809 y_prime * (-std::sin(W*DD2R)*std::cos(O*DD2R) - std::cos(W*DD2R)*std::sin(O*DD2R)*std::cos(I*DD2R)) ;
810 double y_ecl = x_prime * (std::cos(W*DD2R)*std::sin(O*DD2R) + std::sin(W*DD2R)*std::cos(O*DD2R)*std::cos(I*DD2R)) +
811 y_prime * (-std::sin(W*DD2R)*std::sin(O*DD2R) + std::cos(W*DD2R)*std::cos(O*DD2R)*std::cos(I*DD2R)) ;
812 double z_ecl = x_prime * (std::sin(W*DD2R)*std::sin(I*DD2R)) + y_prime * (std::cos(W*DD2R)*std::sin(I*DD2R)) ;
815 double obl = DD2R * 23.43928 ;
816 pos_icrs_[0] = x_ecl ;
817 pos_icrs_[1] = y_ecl * std::cos(obl) - z_ecl * std::sin(obl) ;
818 pos_icrs_[2] = y_ecl * std::sin(obl) + z_ecl * std::cos(obl) ;
831 double perihelion_long_deg,
834 double M = mean_longitude_deg - perihelion_long_deg + (b_*T*T)
835 + c_*std::cos(f_*T*DD2R) + s_*std::sin(f_*T*DD2R) ;
837 while (M>180.0) M-=360.0 ;
838 while (M<-180.0) M+=360.0 ;
860 del_E = (M - (En - e*DR2D*std::sin(En*DD2R))) / (1.0-e*std::cos(En*DD2R)) ;
863 if ( std::fabs(del_E) < E_tol) {
869 return EccentricAnomoly(M, e, En, del_E) ;
881 if (reference_ !=
nullptr) {
884 reference_ =
nullptr;
887 reference_ = reference;
890 cached_jd_ = -1.0e30;
902 if ((new_id < 1.0)||(new_id > 8.0)) {
905 sofa_planet_id_ = new_id;
924 if (reference_ !=
nullptr) {
926 reference_ =
nullptr;
985 reference_ =
nullptr;
995 cached_jd_ = -1.0e30;
996 pos_icrs_ = std::vector<double>(3, 0.0);
998 vel_icrs_ = std::vector<double>(3, 0.0);
1004 semi_major_axis_au_ = 0.0;
1005 eccentricity_ = 0.0;
1006 inclination_deg_ = 0.0;
1007 mean_longitude_deg_ = 0.0;
1008 perihelion_lon_deg_ = 0.0;
1009 ascending_node_lon_deg_ = 0.0;
1012 semi_major_axis_au_per_cent_ = 0.0;
1013 eccentricity_per_cent_ = 0.0;
1014 inclination_deg_per_cent_ = 0.0;
1015 mean_longitude_deg_per_cent_ = 0.0;
1016 perihelion_long_deg_per_cent_ = 0.0;
1017 ascending_node_lon_deg_per_cent_ = 0.0;
1036 if (reference_ !=
nullptr) {
1038 reference_ =
nullptr;