siderust-cpp 0.8.0
Header-only C++ wrapper for siderust
Loading...
Searching...
No Matches
centers.hpp
Go to the documentation of this file.
1#pragma once
2
13#include "ffi_core.hpp"
14
15namespace siderust {
16
17// Forward declaration for Geodetic (defined in coordinates/geodetic.hpp)
18struct Geodetic;
19
20namespace centers {
21
22// ============================================================================
23// Center Trait
24// ============================================================================
25
26template <typename C> struct CenterTraits; // primary — intentionally undefined
27
28template <typename C, typename = void> struct is_center : std::false_type {};
29
30template <typename C>
31struct is_center<C, std::void_t<decltype(CenterTraits<C>::ffi_id)>> : std::true_type {};
32
33template <typename C> inline constexpr bool is_center_v = is_center<C>::value;
34
35// ============================================================================
36// Center Tag Definitions
37// ============================================================================
38
40struct Barycentric {};
42struct Heliocentric {};
44struct Geocentric {};
46struct Topocentric {};
48struct Bodycentric {};
49
50// ============================================================================
51// CenterTraits Specializations
52// ============================================================================
53
55struct NoParams {};
56
57template <> struct CenterTraits<Barycentric> {
58 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_BARYCENTRIC;
60 static constexpr const char *name() { return "Barycentric"; }
61};
62
63template <> struct CenterTraits<Heliocentric> {
64 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_HELIOCENTRIC;
66 static constexpr const char *name() { return "Heliocentric"; }
67};
68
69template <> struct CenterTraits<Geocentric> {
70 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_GEOCENTRIC;
72 static constexpr const char *name() { return "Geocentric"; }
73};
74
75template <> struct CenterTraits<Topocentric> {
76 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_TOPOCENTRIC;
77 using Params = Geodetic; // forward-declared
78 static constexpr const char *name() { return "Topocentric"; }
79};
80
81template <> struct CenterTraits<Bodycentric> {
82 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_BODYCENTRIC;
83 using Params = NoParams; // placeholder for BodycentricParams
84 static constexpr const char *name() { return "Bodycentric"; }
85};
86
87// ============================================================================
88// Center-shift Valid Predicate
89// ============================================================================
90
97template <typename From, typename To> struct has_center_transform : std::false_type {};
98
99template <typename C> struct has_center_transform<C, C> : std::true_type {};
100
101#define SIDERUST_CENTER_TRANSFORM_PAIR(A, B) \
102 template <> struct has_center_transform<A, B> : std::true_type {}; \
103 template <> struct has_center_transform<B, A> : std::true_type {}
104
108
109#undef SIDERUST_CENTER_TRANSFORM_PAIR
110
111template <typename From, typename To>
113
114} // namespace centers
115} // namespace siderust
#define SIDERUST_CENTER_TRANSFORM_PAIR(A, B)
Definition centers.hpp:101
Error handling and utility base for the siderust C++ wrapper.
constexpr bool is_center_v
Definition centers.hpp:33
constexpr bool has_center_transform_v
Definition centers.hpp:112
Geodetic position (WGS84 ellipsoid).
Definition geodetic.hpp:29
Solar-system barycenter (zero-cost, Params = void).
Definition centers.hpp:40
Center of a body (Params = BodycentricParams).
Definition centers.hpp:48
static constexpr const char * name()
Definition centers.hpp:60
static constexpr const char * name()
Definition centers.hpp:84
static constexpr const char * name()
Definition centers.hpp:72
static constexpr const char * name()
Definition centers.hpp:66
static constexpr const char * name()
Definition centers.hpp:78
Geocenter (zero-cost, Params = void).
Definition centers.hpp:44
Heliocenter (zero-cost, Params = void).
Definition centers.hpp:42
Marker for simple (no-parameter) centers.
Definition centers.hpp:55
Observer on Earth's surface (Params = Geodetic).
Definition centers.hpp:46
Marks center pairs for which a CenterShiftProvider exists.
Definition centers.hpp:97