Coordinate systems and frame transform walkthrough.
Coordinate systems and frame transform walkthrough.Usage: cmake –build build-make –target coordinate_systems_example ./build-make/coordinate_systems_example
#include <cstdio>
using namespace qtty::literals;
std::printf("=== Coordinate Systems Example ===\n\n");
auto obs = ROQUE_DE_LOS_MUCHACHOS;
auto jd = JulianDate::from_utc({2026, 7, 15, 22, 0, 0});
std::printf("Observer (Geodetic): lon=%.4f deg lat=%.4f deg h=%.1f m\n",
obs.lon.value(), obs.lat.value(), obs.height.value());
auto ecef_m = obs.to_cartesian<qtty::Meter>();
auto ecef_km = obs.to_cartesian<qtty::Kilometer>();
std::printf("Observer (ECEF): x=%.2f m y=%.2f m z=%.2f m\n",
ecef_m.x().value(), ecef_m.y().value(), ecef_m.z().value());
std::printf("Observer (ECEF): x=%.2f km y=%.2f km z=%.2f km\n\n",
ecef_km.x().value(), ecef_km.y().value(), ecef_km.z().value());
auto vega_back = vega_ecl.to<
ICRS>(jd);
std::printf("Vega ICRS: RA=%.6f Dec=%.6f\n",
vega_icrs.
ra().value(), vega_icrs.
dec().value());
std::printf("Vega EclipticMeanJ2000: lon=%.6f lat=%.6f\n",
vega_ecl.lon().value(), vega_ecl.lat().value());
std::printf("Vega EquatorialMeanOfDate: RA=%.6f Dec=%.6f\n",
vega_eq_mod.ra().value(), vega_eq_mod.dec().value());
std::printf("Vega EquatorialTrueOfDate: RA=%.6f Dec=%.6f\n",
vega_eq_tod.ra().value(), vega_eq_tod.dec().value());
std::printf("Vega Horizontal: az=%.6f alt=%.6f\n",
vega_hor.az().value(), vega_hor.alt().value());
std::printf("Vega roundtrip ICRS<-Ecliptic: RA=%.6f Dec=%.6f\n\n",
vega_back.ra().value(), vega_back.dec().value());
120.0_deg, -25.0_deg, 2.0_au);
std::printf("Spherical ICRS position: RA=%.2f Dec=%.2f dist=%.3f AU\n",
target_sph_au.
ra().value(),
target_sph_au.
dec().value(),
std::printf("Direction extracted from spherical position: RA=%.2f Dec=%.2f\n\n",
target_dir.ra().value(), target_dir.dec().value());
target_cart_m.
x().to<qtty::AstronomicalUnit>(),
target_cart_m.
y().to<qtty::AstronomicalUnit>(),
target_cart_m.
z().to<qtty::AstronomicalUnit>());
std::printf("Cartesian ICRS position: x=%.3e m y=%.3e m z=%.3e m\n",
target_cart_m.
x().value(),
target_cart_m.
y().value(),
target_cart_m.
z().value());
std::printf("Cartesian ICRS position: x=%.6f AU y=%.6f AU z=%.6f AU\n",
target_cart_au.
x().value(),
target_cart_au.
y().value(),
target_cart_au.
z().value());
return 0;
}
Umbrella header for the siderust C++ wrapper library.
A 3D Cartesian position, compile-time tagged by center, frame, unit.
Mean ecliptic & equinox of J2000.0.
Mean equatorial of date (precessed, no nutation).
True equatorial of date (precessed + nutated).
International Celestial Reference System.
A direction on the celestial sphere, compile-time tagged by frame.
std::enable_if_t< frames::has_horizontal_transform_v< F_ >, Direction< frames::Horizontal > > to_horizontal(const JulianDate &jd, const Geodetic &observer) const
Transform to the horizontal (alt-az) frame.
auto to(const JulianDate &jd) const -> decltype(this->template to_frame< Target >(jd))
Shorthand: .to<Target>(jd) (calls to_frame).
A spherical position (direction + distance), compile-time tagged.
Direction< F > direction() const
Extract the direction component.