siderust-cpp
Header-only C++ wrapper for siderust
Loading...
Searching...
No Matches
frames.hpp
Go to the documentation of this file.
1#pragma once
2
12#include "ffi_core.hpp"
13
14namespace siderust {
15namespace frames {
16
17// ============================================================================
18// Frame Trait
19// ============================================================================
20
27template <typename F>
28struct FrameTraits; // primary template — intentionally undefined
29
33template <typename F, typename = void>
34struct is_frame : std::false_type {};
35
36template <typename F>
37struct is_frame<F, std::void_t<decltype(FrameTraits<F>::ffi_id)>> : std::true_type {};
38
39template <typename F>
40inline constexpr bool is_frame_v = is_frame<F>::value;
41
42// ============================================================================
43// Frame Tag Definitions
44// ============================================================================
45
47struct ICRS {};
49struct ICRF {};
63struct Horizontal {};
65struct Galactic {};
67struct ECEF {};
69struct ITRF {};
71struct CIRS {};
73struct GCRS {};
75struct TIRS {};
78
79// ============================================================================
80// FrameTraits Specializations
81// ============================================================================
82
83#define SIDERUST_DEFINE_FRAME(Tag, EnumVal, Label) \
84 template <> \
85 struct FrameTraits<Tag> { \
86 static constexpr siderust_frame_t ffi_id = EnumVal; \
87 static constexpr const char* name() { return Label; } \
88 }
89
90SIDERUST_DEFINE_FRAME(ICRS, SIDERUST_FRAME_T_ICRS, "ICRS");
91SIDERUST_DEFINE_FRAME(ICRF, SIDERUST_FRAME_T_ICRF, "ICRF");
92SIDERUST_DEFINE_FRAME(EclipticMeanJ2000, SIDERUST_FRAME_T_ECLIPTIC_MEAN_J2000, "EclipticMeanJ2000");
93SIDERUST_DEFINE_FRAME(EclipticOfDate, SIDERUST_FRAME_T_ECLIPTIC_OF_DATE, "EclipticOfDate");
94SIDERUST_DEFINE_FRAME(EclipticTrueOfDate, SIDERUST_FRAME_T_ECLIPTIC_TRUE_OF_DATE, "EclipticTrueOfDate");
95SIDERUST_DEFINE_FRAME(EquatorialMeanJ2000, SIDERUST_FRAME_T_EQUATORIAL_MEAN_J2000, "EquatorialMeanJ2000");
96SIDERUST_DEFINE_FRAME(EquatorialMeanOfDate, SIDERUST_FRAME_T_EQUATORIAL_MEAN_OF_DATE, "EquatorialMeanOfDate");
97SIDERUST_DEFINE_FRAME(EquatorialTrueOfDate, SIDERUST_FRAME_T_EQUATORIAL_TRUE_OF_DATE, "EquatorialTrueOfDate");
98SIDERUST_DEFINE_FRAME(Horizontal, SIDERUST_FRAME_T_HORIZONTAL, "Horizontal");
99SIDERUST_DEFINE_FRAME(Galactic, SIDERUST_FRAME_T_GALACTIC, "Galactic");
100SIDERUST_DEFINE_FRAME(ECEF, SIDERUST_FRAME_T_ECEF, "ECEF");
101SIDERUST_DEFINE_FRAME(ITRF, SIDERUST_FRAME_T_ITRF, "ITRF");
102SIDERUST_DEFINE_FRAME(CIRS, SIDERUST_FRAME_T_CIRS, "CIRS");
103SIDERUST_DEFINE_FRAME(GCRS, SIDERUST_FRAME_T_GCRS, "GCRS");
104SIDERUST_DEFINE_FRAME(TIRS, SIDERUST_FRAME_T_TIRS, "TIRS");
105
106#undef SIDERUST_DEFINE_FRAME
107
108// ============================================================================
109// Naming Conventions (Spherical)
110// ============================================================================
111
117template <typename F>
119 static constexpr const char* lon_name() { return "longitude"; }
120 static constexpr const char* lat_name() { return "latitude"; }
121};
122
123template <>
125 static constexpr const char* lon_name() { return "right_ascension"; }
126 static constexpr const char* lat_name() { return "declination"; }
127};
128
129template <>
131 static constexpr const char* lon_name() { return "right_ascension"; }
132 static constexpr const char* lat_name() { return "declination"; }
133};
134
135template <>
137 static constexpr const char* lon_name() { return "right_ascension"; }
138 static constexpr const char* lat_name() { return "declination"; }
139};
140
141template <>
143 static constexpr const char* lon_name() { return "right_ascension"; }
144 static constexpr const char* lat_name() { return "declination"; }
145};
146
147template <>
149 static constexpr const char* lon_name() { return "right_ascension"; }
150 static constexpr const char* lat_name() { return "declination"; }
151};
152
153template <>
155 static constexpr const char* lon_name() { return "azimuth"; }
156 static constexpr const char* lat_name() { return "altitude"; }
157};
158
159template <>
161 static constexpr const char* lon_name() { return "l"; }
162 static constexpr const char* lat_name() { return "b"; }
163};
164
165template <>
167 static constexpr const char* lon_name() { return "ecliptic_longitude"; }
168 static constexpr const char* lat_name() { return "ecliptic_latitude"; }
169};
170
171// ============================================================================
172// Frame Capability Traits
173// ============================================================================
174
180template <typename F>
181struct has_ra_dec : std::false_type {};
182template <>
183struct has_ra_dec<ICRS> : std::true_type {};
184template <>
185struct has_ra_dec<ICRF> : std::true_type {};
186template <>
187struct has_ra_dec<EquatorialMeanJ2000> : std::true_type {};
188template <>
189struct has_ra_dec<EquatorialMeanOfDate> : std::true_type {};
190template <>
191struct has_ra_dec<EquatorialTrueOfDate> : std::true_type {};
192template <typename F>
193inline constexpr bool has_ra_dec_v = has_ra_dec<F>::value;
194
200template <typename F>
201struct has_az_alt : std::false_type {};
202template <>
203struct has_az_alt<Horizontal> : std::true_type {};
204template <typename F>
205inline constexpr bool has_az_alt_v = has_az_alt<F>::value;
206
212template <typename F>
213struct has_lon_lat : std::false_type {};
214template <>
215struct has_lon_lat<EclipticMeanJ2000> : std::true_type {};
216template <>
217struct has_lon_lat<EclipticOfDate> : std::true_type {};
218template <>
219struct has_lon_lat<EclipticTrueOfDate> : std::true_type {};
220template <>
221struct has_lon_lat<Galactic> : std::true_type {};
222template <>
223struct has_lon_lat<CIRS> : std::true_type {};
224template <>
225struct has_lon_lat<GCRS> : std::true_type {};
226template <>
227struct has_lon_lat<TIRS> : std::true_type {};
228template <>
229struct has_lon_lat<ECEF> : std::true_type {};
230template <>
231struct has_lon_lat<ITRF> : std::true_type {};
232template <typename F>
233inline constexpr bool has_lon_lat_v = has_lon_lat<F>::value;
234
235// ============================================================================
236// Transform-Valid Predicate
237// ============================================================================
238
249template <typename From, typename To>
250struct has_frame_transform : std::false_type {};
251
252// Identity
253template <typename F>
254struct has_frame_transform<F, F> : std::true_type {};
255
256// Hub spokes (bidirectional)
257#define SIDERUST_FRAME_TRANSFORM_PAIR(A, B) \
258 template <> \
259 struct has_frame_transform<A, B> : std::true_type {}; \
260 template <> \
261 struct has_frame_transform<B, A> : std::true_type {}
262
263// All pairs reachable through the ICRS hub
274// ICRF ≡ ICRS
280
281#undef SIDERUST_FRAME_TRANSFORM_PAIR
282
283template <typename From, typename To>
285
289template <typename F>
290struct has_horizontal_transform : std::false_type {};
291
292template <>
293struct has_horizontal_transform<ICRS> : std::true_type {};
294template <>
295struct has_horizontal_transform<ICRF> : std::true_type {};
296template <>
297struct has_horizontal_transform<EclipticMeanJ2000> : std::true_type {};
298template <>
300template <>
302template <>
304
305template <typename F>
307
308} // namespace frames
309} // namespace siderust
Error handling and utility base for the siderust C++ wrapper.
#define SIDERUST_DEFINE_FRAME(Tag, EnumVal, Label)
Definition frames.hpp:83
#define SIDERUST_FRAME_TRANSFORM_PAIR(A, B)
Definition frames.hpp:257
constexpr bool has_lon_lat_v
Definition frames.hpp:233
constexpr bool has_ra_dec_v
Definition frames.hpp:193
constexpr bool is_frame_v
Definition frames.hpp:40
constexpr bool has_frame_transform_v
Definition frames.hpp:284
constexpr bool has_az_alt_v
Definition frames.hpp:205
constexpr bool has_horizontal_transform_v
Definition frames.hpp:306
Celestial Intermediate Reference System.
Definition frames.hpp:71
Earth-Centered Earth-Fixed.
Definition frames.hpp:67
Mean ecliptic & equinox of J2000.0.
Definition frames.hpp:51
Ecliptic mean of date (alias for EclipticOfDate).
Definition frames.hpp:77
Ecliptic of date (precessed mean obliquity, no nutation).
Definition frames.hpp:53
True ecliptic of date (precessed + nutated).
Definition frames.hpp:55
Mean equatorial of J2000.0 (FK5-aligned).
Definition frames.hpp:57
Mean equatorial of date (precessed, no nutation).
Definition frames.hpp:59
True equatorial of date (precessed + nutated).
Definition frames.hpp:61
SFINAE helper: every frame tag must provide these static members.
Definition frames.hpp:28
Geocentric Celestial Reference System.
Definition frames.hpp:73
Galactic coordinate system (IAU 1958).
Definition frames.hpp:65
Local horizontal (topocentric alt-az).
Definition frames.hpp:63
International Celestial Reference Frame (treated ≡ ICRS).
Definition frames.hpp:49
International Celestial Reference System.
Definition frames.hpp:47
International Terrestrial Reference Frame.
Definition frames.hpp:69
static constexpr const char * lon_name()
Definition frames.hpp:161
static constexpr const char * lat_name()
Definition frames.hpp:162
static constexpr const char * lon_name()
Definition frames.hpp:155
static constexpr const char * lat_name()
Definition frames.hpp:156
static constexpr const char * lat_name()
Definition frames.hpp:132
static constexpr const char * lon_name()
Definition frames.hpp:131
static constexpr const char * lat_name()
Definition frames.hpp:126
static constexpr const char * lon_name()
Definition frames.hpp:125
Maps a frame to its conventional spherical-coordinate names.
Definition frames.hpp:118
static constexpr const char * lon_name()
Definition frames.hpp:119
static constexpr const char * lat_name()
Definition frames.hpp:120
Terrestrial Intermediate Reference System.
Definition frames.hpp:75
True for the horizontal frame that exposes azimuth / altitude.
Definition frames.hpp:201
Marks frame pairs for which a FrameRotationProvider exists in siderust-ffi.
Definition frames.hpp:250
Marks frames from which to_horizontal is reachable.
Definition frames.hpp:290
True for ecliptic and galactic frames that use longitude / latitude.
Definition frames.hpp:213
True for equatorial frames that expose right-ascension / declination.
Definition frames.hpp:181
Concept-like compile-time check (C++17: constexpr bool).
Definition frames.hpp:34