siderust-cpp
Header-only C++ wrapper for siderust
Loading...
Searching...
No Matches
coordinate_systems_example.cpp
Go to the documentation of this file.
1
11#include <siderust/siderust.hpp>
12
13#include <cstdio>
14
15using namespace siderust;
16using namespace siderust::frames;
17using namespace qtty::literals;
18
19int main() {
20 std::printf("=== Coordinate Systems Example ===\n\n");
21
22 auto obs = ROQUE_DE_LOS_MUCHACHOS;
23 auto jd = JulianDate::from_utc({2026, 7, 15, 22, 0, 0});
24
25 std::printf("Observer (Geodetic): lon=%.4f deg lat=%.4f deg h=%.1f m\n",
26 obs.lon.value(), obs.lat.value(), obs.height.value());
27
28 auto ecef_m = obs.to_cartesian<qtty::Meter>();
29 auto ecef_km = obs.to_cartesian<qtty::Kilometer>();
30 std::printf("Observer (ECEF): x=%.2f m y=%.2f m z=%.2f m\n",
31 ecef_m.x().value(), ecef_m.y().value(), ecef_m.z().value());
32 std::printf("Observer (ECEF): x=%.2f km y=%.2f km z=%.2f km\n\n",
33 ecef_km.x().value(), ecef_km.y().value(), ecef_km.z().value());
34
35 // Vega J2000 ICRS direction.
36 spherical::direction::ICRS vega_icrs(279.23473, 38.78369);
37
38 auto vega_ecl = vega_icrs.to<EclipticMeanJ2000>(jd);
39 auto vega_eq_mod = vega_icrs.to<EquatorialMeanOfDate>(jd);
40 auto vega_eq_tod = vega_icrs.to<EquatorialTrueOfDate>(jd);
41 auto vega_hor = vega_icrs.to_horizontal(jd, obs);
42 auto vega_back = vega_ecl.to<ICRS>(jd);
43
44 std::printf("Vega ICRS: RA=%.6f Dec=%.6f\n",
45 vega_icrs.ra().value(), vega_icrs.dec().value());
46 std::printf("Vega EclipticMeanJ2000: lon=%.6f lat=%.6f\n",
47 vega_ecl.lon().value(), vega_ecl.lat().value());
48 std::printf("Vega EquatorialMeanOfDate: RA=%.6f Dec=%.6f\n",
49 vega_eq_mod.ra().value(), vega_eq_mod.dec().value());
50 std::printf("Vega EquatorialTrueOfDate: RA=%.6f Dec=%.6f\n",
51 vega_eq_tod.ra().value(), vega_eq_tod.dec().value());
52 std::printf("Vega Horizontal: az=%.6f alt=%.6f\n",
53 vega_hor.az().value(), vega_hor.alt().value());
54 std::printf("Vega roundtrip ICRS<-Ecliptic: RA=%.6f Dec=%.6f\n\n",
55 vega_back.ra().value(), vega_back.dec().value());
56
58 120.0_deg, -25.0_deg, 2.0_au);
59 auto target_dir = target_sph_au.direction();
60 std::printf("Spherical ICRS position: RA=%.2f Dec=%.2f dist=%.3f AU\n",
61 target_sph_au.ra().value(),
62 target_sph_au.dec().value(),
63 target_sph_au.distance().value());
64 std::printf("Direction extracted from spherical position: RA=%.2f Dec=%.2f\n\n",
65 target_dir.ra().value(), target_dir.dec().value());
66
67 cartesian::position::ICRS<qtty::Meter> target_cart_m(1.5e11, -3.0e10, 2.0e10);
69 target_cart_m.x().to<qtty::AstronomicalUnit>(),
70 target_cart_m.y().to<qtty::AstronomicalUnit>(),
71 target_cart_m.z().to<qtty::AstronomicalUnit>());
72
73 std::printf("Cartesian ICRS position: x=%.3e m y=%.3e m z=%.3e m\n",
74 target_cart_m.x().value(),
75 target_cart_m.y().value(),
76 target_cart_m.z().value());
77 std::printf("Cartesian ICRS position: x=%.6f AU y=%.6f AU z=%.6f AU\n",
78 target_cart_au.x().value(),
79 target_cart_au.y().value(),
80 target_cart_au.z().value());
81
82 return 0;
83}
const Geodetic ROQUE_DE_LOS_MUCHACHOS
Roque de los Muchachos Observatory (La Palma, Spain).
Umbrella header for the siderust C++ wrapper library.
A 3D Cartesian position, compile-time tagged by center, frame, unit.
Definition cartesian.hpp:53
Mean ecliptic & equinox of J2000.0.
Definition frames.hpp:51
Mean equatorial of date (precessed, no nutation).
Definition frames.hpp:59
True equatorial of date (precessed + nutated).
Definition frames.hpp:61
International Celestial Reference System.
Definition frames.hpp:47
A direction on the celestial sphere, compile-time tagged by frame.
Definition spherical.hpp:36
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).
qtty::Degree dec() const
Definition spherical.hpp:69
qtty::Degree ra() const
Definition spherical.hpp:66
A spherical position (direction + distance), compile-time tagged.
Direction< F > direction() const
Extract the direction component.
qtty::Degree ra() const
qtty::Degree dec() const