siderust-cpp 0.8.0
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> struct FrameTraits; // primary template — intentionally undefined
28
32template <typename F, typename = void> struct is_frame : std::false_type {};
33
34template <typename F>
35struct is_frame<F, std::void_t<decltype(FrameTraits<F>::ffi_id)>> : std::true_type {};
36
37template <typename F> inline constexpr bool is_frame_v = is_frame<F>::value;
38
39// ============================================================================
40// Frame Tag Definitions
41// ============================================================================
42
44struct ICRS {};
46struct ICRF {};
60struct Horizontal {};
62struct Galactic {};
64struct ECEF {};
66struct ITRF {};
68struct CIRS {};
70struct GCRS {};
72struct TIRS {};
75
76// ============================================================================
77// FrameTraits Specializations
78// ============================================================================
79
80#define SIDERUST_DEFINE_FRAME(Tag, EnumVal, Label) \
81 template <> struct FrameTraits<Tag> { \
82 static constexpr siderust_frame_t ffi_id = EnumVal; \
83 static constexpr const char *name() { return Label; } \
84 }
85
86SIDERUST_DEFINE_FRAME(ICRS, SIDERUST_FRAME_T_ICRS, "ICRS");
87SIDERUST_DEFINE_FRAME(ICRF, SIDERUST_FRAME_T_ICRF, "ICRF");
88SIDERUST_DEFINE_FRAME(EclipticMeanJ2000, SIDERUST_FRAME_T_ECLIPTIC_MEAN_J2000, "EclipticMeanJ2000");
89SIDERUST_DEFINE_FRAME(EclipticOfDate, SIDERUST_FRAME_T_ECLIPTIC_OF_DATE, "EclipticOfDate");
90SIDERUST_DEFINE_FRAME(EclipticTrueOfDate, SIDERUST_FRAME_T_ECLIPTIC_TRUE_OF_DATE,
91 "EclipticTrueOfDate");
92SIDERUST_DEFINE_FRAME(EquatorialMeanJ2000, SIDERUST_FRAME_T_EQUATORIAL_MEAN_J2000,
93 "EquatorialMeanJ2000");
94SIDERUST_DEFINE_FRAME(EquatorialMeanOfDate, SIDERUST_FRAME_T_EQUATORIAL_MEAN_OF_DATE,
95 "EquatorialMeanOfDate");
96SIDERUST_DEFINE_FRAME(EquatorialTrueOfDate, SIDERUST_FRAME_T_EQUATORIAL_TRUE_OF_DATE,
97 "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
118template <typename F> struct SphericalNaming {
119 static constexpr const char *lon_name() { return "longitude"; }
120 static constexpr const char *lat_name() { return "latitude"; }
121};
122
123template <> struct SphericalNaming<ICRS> {
124 static constexpr const char *lon_name() { return "right_ascension"; }
125 static constexpr const char *lat_name() { return "declination"; }
126};
127
128template <> struct SphericalNaming<ICRF> {
129 static constexpr const char *lon_name() { return "right_ascension"; }
130 static constexpr const char *lat_name() { return "declination"; }
131};
132
134 static constexpr const char *lon_name() { return "right_ascension"; }
135 static constexpr const char *lat_name() { return "declination"; }
136};
137
139 static constexpr const char *lon_name() { return "right_ascension"; }
140 static constexpr const char *lat_name() { return "declination"; }
141};
142
144 static constexpr const char *lon_name() { return "right_ascension"; }
145 static constexpr const char *lat_name() { return "declination"; }
146};
147
148template <> struct SphericalNaming<Horizontal> {
149 static constexpr const char *lon_name() { return "azimuth"; }
150 static constexpr const char *lat_name() { return "altitude"; }
151};
152
153template <> struct SphericalNaming<Galactic> {
154 static constexpr const char *lon_name() { return "l"; }
155 static constexpr const char *lat_name() { return "b"; }
156};
157
159 static constexpr const char *lon_name() { return "ecliptic_longitude"; }
160 static constexpr const char *lat_name() { return "ecliptic_latitude"; }
161};
162
163// ============================================================================
164// Frame Capability Traits
165// ============================================================================
166
172template <typename F> struct has_ra_dec : std::false_type {};
173template <> struct has_ra_dec<ICRS> : std::true_type {};
174template <> struct has_ra_dec<ICRF> : std::true_type {};
175template <> struct has_ra_dec<EquatorialMeanJ2000> : std::true_type {};
176template <> struct has_ra_dec<EquatorialMeanOfDate> : std::true_type {};
177template <> struct has_ra_dec<EquatorialTrueOfDate> : std::true_type {};
178template <typename F> inline constexpr bool has_ra_dec_v = has_ra_dec<F>::value;
179
185template <typename F> struct has_az_alt : std::false_type {};
186template <> struct has_az_alt<Horizontal> : std::true_type {};
187template <typename F> inline constexpr bool has_az_alt_v = has_az_alt<F>::value;
188
194template <typename F> struct has_lon_lat : std::false_type {};
195template <> struct has_lon_lat<EclipticMeanJ2000> : std::true_type {};
196template <> struct has_lon_lat<EclipticOfDate> : std::true_type {};
197template <> struct has_lon_lat<EclipticTrueOfDate> : std::true_type {};
198template <> struct has_lon_lat<Galactic> : std::true_type {};
199template <> struct has_lon_lat<CIRS> : std::true_type {};
200template <> struct has_lon_lat<GCRS> : std::true_type {};
201template <> struct has_lon_lat<TIRS> : std::true_type {};
202template <> struct has_lon_lat<ECEF> : std::true_type {};
203template <> struct has_lon_lat<ITRF> : std::true_type {};
204template <typename F> inline constexpr bool has_lon_lat_v = has_lon_lat<F>::value;
205
206// ============================================================================
207// Transform-Valid Predicate
208// ============================================================================
209
220template <typename From, typename To> struct has_frame_transform : std::false_type {};
221
222// Identity
223template <typename F> struct has_frame_transform<F, F> : std::true_type {};
224
225// Hub spokes (bidirectional)
226#define SIDERUST_FRAME_TRANSFORM_PAIR(A, B) \
227 template <> struct has_frame_transform<A, B> : std::true_type {}; \
228 template <> struct has_frame_transform<B, A> : std::true_type {}
229
230// All pairs reachable through the ICRS hub
241// ICRF ≡ ICRS
247
248#undef SIDERUST_FRAME_TRANSFORM_PAIR
249
250template <typename From, typename To>
252
256template <typename F> struct has_horizontal_transform : std::false_type {};
257
258template <> struct has_horizontal_transform<ICRS> : std::true_type {};
259template <> struct has_horizontal_transform<ICRF> : std::true_type {};
260template <> struct has_horizontal_transform<EclipticMeanJ2000> : std::true_type {};
261template <> struct has_horizontal_transform<EquatorialMeanJ2000> : std::true_type {};
262template <> struct has_horizontal_transform<EquatorialMeanOfDate> : std::true_type {};
263template <> struct has_horizontal_transform<EquatorialTrueOfDate> : std::true_type {};
264
265template <typename F>
267
268} // namespace frames
269} // namespace siderust
Error handling and utility base for the siderust C++ wrapper.
#define SIDERUST_DEFINE_FRAME(Tag, EnumVal, Label)
Definition frames.hpp:80
#define SIDERUST_FRAME_TRANSFORM_PAIR(A, B)
Definition frames.hpp:226
constexpr bool has_lon_lat_v
Definition frames.hpp:204
constexpr bool has_ra_dec_v
Definition frames.hpp:178
constexpr bool is_frame_v
Definition frames.hpp:37
constexpr bool has_frame_transform_v
Definition frames.hpp:251
constexpr bool has_az_alt_v
Definition frames.hpp:187
constexpr bool has_horizontal_transform_v
Definition frames.hpp:266
Celestial Intermediate Reference System.
Definition frames.hpp:68
Earth-Centered Earth-Fixed.
Definition frames.hpp:64
Mean ecliptic & equinox of J2000.0.
Definition frames.hpp:48
Ecliptic mean of date (alias for EclipticOfDate).
Definition frames.hpp:74
Ecliptic of date (precessed mean obliquity, no nutation).
Definition frames.hpp:50
True ecliptic of date (precessed + nutated).
Definition frames.hpp:52
Mean equatorial of J2000.0 (FK5-aligned).
Definition frames.hpp:54
Mean equatorial of date (precessed, no nutation).
Definition frames.hpp:56
True equatorial of date (precessed + nutated).
Definition frames.hpp:58
SFINAE helper: every frame tag must provide these static members.
Definition frames.hpp:27
Geocentric Celestial Reference System.
Definition frames.hpp:70
Galactic coordinate system (IAU 1958).
Definition frames.hpp:62
Local horizontal (topocentric alt-az).
Definition frames.hpp:60
International Celestial Reference Frame (treated ≡ ICRS).
Definition frames.hpp:46
International Celestial Reference System.
Definition frames.hpp:44
International Terrestrial Reference Frame.
Definition frames.hpp:66
static constexpr const char * lon_name()
Definition frames.hpp:154
static constexpr const char * lat_name()
Definition frames.hpp:155
static constexpr const char * lon_name()
Definition frames.hpp:149
static constexpr const char * lat_name()
Definition frames.hpp:150
static constexpr const char * lat_name()
Definition frames.hpp:130
static constexpr const char * lon_name()
Definition frames.hpp:129
static constexpr const char * lat_name()
Definition frames.hpp:125
static constexpr const char * lon_name()
Definition frames.hpp:124
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:72
True for the horizontal frame that exposes azimuth / altitude.
Definition frames.hpp:185
Marks frame pairs for which a FrameRotationProvider exists in siderust-ffi.
Definition frames.hpp:220
Marks frames from which to_horizontal is reachable.
Definition frames.hpp:256
True for ecliptic and galactic frames that use longitude / latitude.
Definition frames.hpp:194
True for equatorial frames that expose right-ascension / declination.
Definition frames.hpp:172
Concept-like compile-time check (C++17: constexpr bool).
Definition frames.hpp:32