9#include "../centers.hpp"
10#include "../frames.hpp"
14#include <qtty/qtty.hpp>
37 static_assert(frames::is_frame_v<F>,
"F must be a valid frame tag");
40 qtty::Degree azimuth_;
44 Direction() : azimuth_(qtty::Degree(0)), polar_(qtty::Degree(0)) {}
47 : azimuth_(azimuth), polar_(polar) {}
51 : azimuth_(qtty::Degree(azimuth_deg)), polar_(qtty::Degree(polar_deg)) {}
65 template <
typename F_ = F, std::enable_if_t<frames::has_ra_dec_v<F_>,
int> = 0>
66 qtty::Degree
ra()
const {
return azimuth_; }
68 template <
typename F_ = F, std::enable_if_t<frames::has_ra_dec_v<F_>,
int> = 0>
69 qtty::Degree
dec()
const {
return polar_; }
74 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
75 qtty::Degree
az()
const {
return azimuth_; }
77 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
78 qtty::Degree
al()
const {
return polar_; }
80 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
81 qtty::Degree
alt()
const {
return polar_; }
83 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
84 qtty::Degree
altitude()
const {
return polar_; }
89 template <
typename F_ = F, std::enable_if_t<frames::has_lon_lat_v<F_>,
int> = 0>
90 qtty::Degree
lon()
const {
return azimuth_; }
92 template <
typename F_ = F, std::enable_if_t<frames::has_lon_lat_v<F_>,
int> = 0>
93 qtty::Degree
lat()
const {
return polar_; }
95 template <
typename F_ = F, std::enable_if_t<frames::has_lon_lat_v<F_>,
int> = 0>
98 template <
typename F_ = F, std::enable_if_t<frames::has_lon_lat_v<F_>,
int> = 0>
99 qtty::Degree
latitude()
const {
return polar_; }
104 siderust_spherical_dir_t
to_c()
const {
105 return {azimuth_.value(), polar_.value(),
frame_id()};
121 template <
typename Target>
123 frames::has_frame_transform_v<F, Target>,
126 if constexpr (std::is_same_v<F, Target>) {
129 siderust_spherical_dir_t out;
131 siderust_spherical_dir_transform_frame(
132 azimuth_.value(), polar_.value(),
136 "Direction::to_frame");
144 template <
typename Target>
146 ->
decltype(this->
template to_frame<Target>(jd)) {
147 return to_frame<Target>(jd);
153 template <
typename F_ = F>
155 frames::has_horizontal_transform_v<F_>,
158 siderust_spherical_dir_t out;
160 siderust_spherical_dir_to_horizontal(
161 azimuth_.value(), polar_.value(),
163 jd.value(), observer.
to_c(), &out),
164 "Direction::to_horizontal");
179template <
typename C,
typename F,
typename U = qtty::Meter>
181 static_assert(frames::is_frame_v<F>,
"F must be a valid frame tag");
182 static_assert(centers::is_center_v<C>,
"C must be a valid center tag");
185 qtty::Degree azimuth_;
191 : azimuth_(qtty::Degree(0)), polar_(qtty::Degree(0)), dist_(U(0)) {}
193 Position(qtty::Degree azimuth, qtty::Degree polar, U dist)
194 : azimuth_(azimuth), polar_(polar), dist_(dist) {}
196 Position(
double azimuth_deg,
double polar_deg,
double dist_val)
197 : azimuth_(qtty::Degree(azimuth_deg)),
198 polar_(qtty::Degree(polar_deg)),
199 dist_(U(dist_val)) {}
208 template <
typename F_ = F, std::enable_if_t<frames::has_ra_dec_v<F_>,
int> = 0>
209 qtty::Degree
ra()
const {
return azimuth_; }
211 template <
typename F_ = F, std::enable_if_t<frames::has_ra_dec_v<F_>,
int> = 0>
212 qtty::Degree
dec()
const {
return polar_; }
214 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
215 qtty::Degree
az()
const {
return azimuth_; }
217 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
218 qtty::Degree
al()
const {
return polar_; }
220 template <
typename F_ = F, std::enable_if_t<frames::has_az_alt_v<F_>,
int> = 0>
221 qtty::Degree
alt()
const {
return polar_; }
223 template <
typename F_ = F, std::enable_if_t<frames::has_lon_lat_v<F_>,
int> = 0>
224 qtty::Degree
lon()
const {
return azimuth_; }
226 template <
typename F_ = F, std::enable_if_t<frames::has_lon_lat_v<F_>,
int> = 0>
227 qtty::Degree
lat()
const {
return polar_; }
void check_status(siderust_status_t status, const char *operation)
tempoch::JulianDate JulianDate
Geodetic position (WGS84 ellipsoid).
siderust_geodetic_t to_c() const
Convert to C FFI struct.
SFINAE helper: every frame tag must provide these static members.
A direction on the celestial sphere, compile-time tagged by frame.
static constexpr siderust_frame_t frame_id()
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Direction< Target > > to_frame(const JulianDate &jd) const
Transform to a different reference frame.
Direction(qtty::Degree azimuth, qtty::Degree polar)
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.
qtty::Degree latitude() const
static constexpr const char * frame_name()
qtty::Degree altitude() const
siderust_spherical_dir_t to_c() const
auto to(const JulianDate &jd) const -> decltype(this->template to_frame< Target >(jd))
Shorthand: .to<Target>(jd) (calls to_frame).
Direction(double azimuth_deg, double polar_deg)
Raw-double convenience (degrees).
qtty::Degree longitude() const
static Direction from_c(const siderust_spherical_dir_t &c)
A spherical position (direction + distance), compile-time tagged.
Position(qtty::Degree azimuth, qtty::Degree polar, U dist)
static constexpr siderust_center_t center_id()
Direction< F > direction() const
Extract the direction component.
static constexpr siderust_frame_t frame_id()
Position(double azimuth_deg, double polar_deg, double dist_val)