siderust-cpp
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>
27struct CenterTraits; // primary — intentionally undefined
28
29template <typename C, typename = void>
30struct is_center : std::false_type {};
31
32template <typename C>
33struct is_center<C, std::void_t<decltype(CenterTraits<C>::ffi_id)>> : std::true_type {};
34
35template <typename C>
36inline constexpr bool is_center_v = is_center<C>::value;
37
38// ============================================================================
39// Center Tag Definitions
40// ============================================================================
41
43struct Barycentric {};
45struct Heliocentric {};
47struct Geocentric {};
49struct Topocentric {};
51struct Bodycentric {};
52
53// ============================================================================
54// CenterTraits Specializations
55// ============================================================================
56
58struct NoParams {};
59
60template <>
62 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_BARYCENTRIC;
64 static constexpr const char* name() { return "Barycentric"; }
65};
66
67template <>
69 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_HELIOCENTRIC;
71 static constexpr const char* name() { return "Heliocentric"; }
72};
73
74template <>
76 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_GEOCENTRIC;
78 static constexpr const char* name() { return "Geocentric"; }
79};
80
81template <>
83 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_TOPOCENTRIC;
84 using Params = Geodetic; // forward-declared
85 static constexpr const char* name() { return "Topocentric"; }
86};
87
88template <>
90 static constexpr siderust_center_t ffi_id = SIDERUST_CENTER_T_BODYCENTRIC;
91 using Params = NoParams; // placeholder for BodycentricParams
92 static constexpr const char* name() { return "Bodycentric"; }
93};
94
95// ============================================================================
96// Center-shift Valid Predicate
97// ============================================================================
98
105template <typename From, typename To>
106struct has_center_transform : std::false_type {};
107
108template <typename C>
109struct has_center_transform<C, C> : std::true_type {};
110
111#define SIDERUST_CENTER_TRANSFORM_PAIR(A, B) \
112 template <> \
113 struct has_center_transform<A, B> : std::true_type {}; \
114 template <> \
115 struct has_center_transform<B, A> : std::true_type {}
116
120
121#undef SIDERUST_CENTER_TRANSFORM_PAIR
122
123template <typename From, typename To>
125
126} // namespace centers
127} // namespace siderust
#define SIDERUST_CENTER_TRANSFORM_PAIR(A, B)
Definition centers.hpp:111
Error handling and utility base for the siderust C++ wrapper.
constexpr bool is_center_v
Definition centers.hpp:36
constexpr bool has_center_transform_v
Definition centers.hpp:124
Geodetic position (WGS84 ellipsoid).
Definition geodetic.hpp:28
Solar-system barycenter (zero-cost, Params = void).
Definition centers.hpp:43
Center of a body (Params = BodycentricParams).
Definition centers.hpp:51
static constexpr const char * name()
Definition centers.hpp:64
static constexpr const char * name()
Definition centers.hpp:92
static constexpr const char * name()
Definition centers.hpp:78
static constexpr const char * name()
Definition centers.hpp:71
static constexpr const char * name()
Definition centers.hpp:85
Geocenter (zero-cost, Params = void).
Definition centers.hpp:47
Heliocenter (zero-cost, Params = void).
Definition centers.hpp:45
Marker for simple (no-parameter) centers.
Definition centers.hpp:58
Observer on Earth's surface (Params = Geodetic).
Definition centers.hpp:49
Marks center pairs for which a CenterShiftProvider exists.
Definition centers.hpp:106