Focused examples for creating and converting typed coordinates.
Focused examples for creating and converting typed coordinates.Usage: cmake –build build-make –target coordinates_examples ./build-make/coordinates_examples
#include <cstdio>
using namespace qtty::literals;
std::printf("1) Geodetic -> ECEF cartesian\n");
Geodetic obs(-17.8890, 28.7610, 2396.0);
std::printf(" Geodetic lon=%.4f deg lat=%.4f deg h=%.1f m\n",
std::printf(" ECEF x=%.2f m y=%.2f m z=%.2f m\n\n",
ecef.x().value(), ecef.y().value(), ecef.z().value());
std::printf(" ECEF x=%.2f km y=%.2f km z=%.2f km\n\n",
ecef_km.x().value(), ecef_km.y().value(), ecef_km.z().value());
}
std::printf("2) Spherical direction frame conversions\n");
auto jd = JulianDate::from_utc({2026, 7, 15, 22, 0, 0});
auto hor = vega_icrs.to_horizontal(jd, ROQUE_DE_LOS_MUCHACHOS);
std::printf(" ICRS RA=%.5f Dec=%.5f\n", vega_icrs.ra().value(), vega_icrs.dec().value());
std::printf(" Ecliptic lon=%.5f lat=%.5f\n", ecl.lon().value(), ecl.lat().value());
std::printf(" Equatorial(MOD) RA=%.5f Dec=%.5f\n", eq_mod.ra().value(), eq_mod.dec().value());
std::printf(" Horizontal az=%.5f alt=%.5f\n\n", hor.az().value(), hor.alt().value());
}
std::printf("3) Spherical position + extracting direction\n");
120.0_deg, -25.0_deg, 2.0e17_m);
auto dir = target.direction();
std::printf(" Position RA=%.2f Dec=%.2f dist=%.3e m\n",
target.ra().value(), target.dec().value(), target.distance().value());
std::printf(" Direction-only RA=%.2f Dec=%.2f\n\n",
dir.ra().value(), dir.dec().value());
}
std::printf("4) Cartesian coordinate creation + unit conversion\n");
auto x_km = sample_helio_au.x().to<qtty::Kilometer>();
auto y_km = sample_helio_au.y().to<qtty::Kilometer>();
std::printf(" Direction<ICRS> x=%.1f y=%.1f z=%.1f\n", axis_x.x, axis_x.y, axis_x.z);
std::printf(" Position<Heliocentric,Ecl,AU> x=%.3f AU y=%.3f AU z=%.3f AU\n",
sample_helio_au.x().value(), sample_helio_au.y().value(), sample_helio_au.z().value());
std::printf(" Same position in km x=%.2f y=%.2f\n\n", x_km.value(), y_km.value());
}
std::printf("5) Typed ephemeris coordinates\n");
auto jd = JulianDate::J2000();
auto earth = ephemeris::earth_heliocentric(jd);
auto moon = ephemeris::moon_geocentric(jd);
std::printf(" Earth heliocentric (AU) x=%.8f y=%.8f z=%.8f\n",
std::printf(" Moon geocentric (km) x=%.3f y=%.3f z=%.3f\n\n",
moon.x().value(), moon.y().value(), moon.z().value());
}
std::printf("=== Coordinate Creation & Conversion Examples ===\n\n");
std::printf("Done.\n");
return 0;
}
static void geodetic_and_ecef_example()
static void spherical_direction_example()
static void cartesian_and_units_example()
static void ephemeris_typed_example()
static void spherical_position_example()
Umbrella header for the siderust C++ wrapper library.
Geodetic position (WGS84 ellipsoid).
qtty::Degree lon
Longitude (east positive).
cartesian::Position< centers::Geocentric, frames::ECEF, U > to_cartesian() const
Convert geodetic (WGS84/ECEF) to cartesian position.
qtty::Degree lat
Latitude (north positive).
qtty::Meter height
Height above ellipsoid.
A unit-vector direction in Cartesian form, compile-time frame-tagged.
A 3D Cartesian position, compile-time tagged by center, frame, unit.
Mean ecliptic & equinox of J2000.0.
Mean equatorial of date (precessed, no nutation).
A direction on the celestial sphere, compile-time tagged by frame.
A spherical position (direction + distance), compile-time tagged.