Target hierarchy, ephemeris snapshots, Kepler propagation, and transforms.
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace qtty::literals;
template <typename P> struct Snapshot {
P position;
position = new_pos;
time = new_time;
}
};
return {17.834_au,
Eccentricity{0.96714}, 162.26_deg, 58.42_deg, 111.33_deg,
}
std::cout << "1) Trackable objects (ICRS, star, Sun, planet, Moon)\n";
ICRSTarget icrs_target(fixed_icrs, jd,
"FixedICRS");
std::cout << " ICRS direction is time-invariant: " << std::fixed << std::setprecision(3)
<< fixed_icrs << std::endl;
std::cout << " Sirius via StarTarget: name = " << sirius_target.name() << '\n';
auto sun_bary = ephemeris::sun_barycentric(jd);
std::cout << " Sun barycentric distance: " << std::fixed << std::setprecision(6)
<< sun_bary.distance() << std::endl;
auto mars_helio = ephemeris::mars_heliocentric(jd);
std::cout << " Mars heliocentric distance: " << std::fixed << std::setprecision(6)
<< mars_helio.distance() << std::endl;
auto moon_geo = ephemeris::moon_geocentric(jd);
std::cout << " Moon geocentric distance: " << std::fixed << std::setprecision(1)
<< moon_geo.distance() << "\n"
<< std::endl;
}
std::cout << "2) Target snapshots for arbitrary sky objects\n";
Snapshot<cartesian::position::EclipticMeanJ2000<qtty::AstronomicalUnit>> mars_snap{
ephemeris::mars_heliocentric(jd), jd};
std::cout << " Mars target at JD " << std::fixed << std::setprecision(1) << mars_snap.time
<< ": r = " << std::setprecision(6) << mars_snap.position.distance() << std::endl;
mars_snap.update(ephemeris::mars_heliocentric(jd_next), jd_next);
std::cout << " Mars target updated to JD " << std::fixed << std::setprecision(1)
<< mars_snap.time << ": r = " << std::setprecision(6) << mars_snap.position.distance()
<< std::endl;
Snapshot<cartesian::position::EclipticMeanJ2000<qtty::AstronomicalUnit>> halley_snap{halley_pos,
jd};
std::cout << " Halley target at JD " << std::fixed << std::setprecision(1) << halley_snap.time
<< ": r = " << std::setprecision(6) << halley_snap.position.distance() << std::endl;
1.0002_au,
Eccentricity{0.001}, 0.1_deg, 35.0_deg, 80.0_deg, 10.0_deg, jd};
Snapshot<cartesian::position::EclipticMeanJ2000<qtty::AstronomicalUnit>> demosat_snap{demosat_pos,
jd};
std::cout << " DemoSat target at JD " << std::fixed << std::setprecision(1) << demosat_snap.time
<< ": r = " << std::setprecision(6) << demosat_snap.position.distance() << "\n"
<< std::endl;
}
constexpr double JULIAN_YEAR = 365.25;
double dt_years = (target_epoch.value() - epoch.value()) / JULIAN_YEAR;
double ra_deg = pos.
ra().value();
double dec_deg = pos.
dec().value();
double cos_dec = std::cos(dec_deg * constants::pi / 180.0);
double dra = (cos_dec > 1e-12) ? pm.
ra.
deg_per_day() * 365.25 * dt_years / cos_dec : 0.0;
}
void section_target_with_proper_motion(
const Time<TT, JD> &jd) {
std::cout << "3) Target with proper motion (stellar-style target)\n";
constexpr double MAS_TO_DEG = 1.0 / 3600000.0;
AngularRate{qtty::Degree(10.86 * MAS_TO_DEG), qtty::Day(365.25)},
RaConvention::MuAlphaStar};
std::cout << " Betelgeuse-like target at J2000: " << betelgeuse_pos << '\n';
constexpr double JULIAN_YEAR = 365.25;
auto jd_future = jd + qtty::Day(25.0 * JULIAN_YEAR);
auto moved = apply_proper_motion(betelgeuse_pos, pm, jd, jd_future);
std::cout << " After 25 years: " << moved << "\n\n";
}
std::cout << "4) Target conversion across frame + center\n";
auto mars_helio = ephemeris::mars_heliocentric(jd);
auto mars_geoeq = mars_helio.template transform<Geocentric, EquatorialMeanJ2000>(jd);
std::cout << " Mars heliocentric ecliptic target: r = " << std::fixed << std::setprecision(6)
<< mars_helio.distance() << std::endl;
std::cout << " Mars geocentric equatorial target: r = " << std::fixed << std::setprecision(6)
<< mars_geoeq.distance() << std::endl;
}
int main() {
auto jd_next = jd + qtty::Day(1.0);
std::cout << "Target + Trackable examples\n"
<< "===========================\n\n";
section_trackable_objects(jd, jd_next);
section_target_snapshots(jd, jd_next);
section_target_with_proper_motion(jd);
section_target_transform(jd);
return 0;
}
Target implementation for solar-system bodies.
Fixed celestial direction target — a Target for a specific sky position.
Target implementation wrapping a const Star&.
tempoch::EncodedTime< Scale, Format > Time
cartesian::Position< C, frames::EclipticMeanJ2000, qtty::AstronomicalUnit > kepler_position(const KeplerianOrbit &orbit, const Time< TT, JD > &jd)
Umbrella header for the siderust C++ wrapper library.
double deg_per_day() const
Proper motion for a star (equatorial).
AngularRate ra
RA proper motion.
AngularRate dec
Dec proper motion.
A direction on the celestial sphere, compile-time tagged by frame.