9#include "../constants.hpp"
16template <
typename C,
typename F,
typename U>
18 const double x = comp_x.value();
19 const double y = comp_y.value();
20 const double z = comp_z.value();
21 const double r = std::sqrt(x * x + y * y + z * z);
25 const double lat = std::atan2(z, std::sqrt(x * x + y * y)) * 180.0 /
constants::pi;
30template <
typename C,
typename F,
typename U>
34 if constexpr (frames::has_ra_dec_v<F>) {
35 lon_deg = azimuth_.value();
36 lat_deg = polar_.value();
37 }
else if constexpr (frames::has_lon_lat_v<F>) {
38 lon_deg = azimuth_.value();
39 lat_deg = polar_.value();
40 }
else if constexpr (frames::has_az_alt_v<F>) {
41 lon_deg = azimuth_.value();
42 lat_deg = polar_.value();
47 const double r = dist_.value();
49 const double cx = r * std::cos(lat) * std::cos(lon);
50 const double cy = r * std::cos(lat) * std::sin(lon);
51 const double cz = r * std::sin(lat);
58template <
typename C,
typename F,
typename U>
59template <
typename Target>
60std::enable_if_t<siderust::frames::has_frame_transform_v<F, Target>,
63 if constexpr (std::is_same_v<F, Target>) {
66 return to_cartesian().template to_frame<Target>(jd).to_spherical();
70template <
typename C,
typename F,
typename U>
71template <
typename Target>
72std::enable_if_t<siderust::frames::has_frame_transform_v<F, Target>,
75 if constexpr (std::is_same_v<F, Target>) {
78 return to_cartesian().template to_frame_with<Target>(jd, ctx).to_spherical();
constexpr double pi
Circle constant pi (radians per half-turn).
tempoch::EncodedTime< Scale, Format > Time
A 3D Cartesian position, compile-time tagged by center, frame, unit.
spherical::Position< C, F, U > to_spherical() const
Convert this cartesian position to a spherical Position<C,F,U>.
A spherical position (direction + distance), compile-time tagged.
cartesian::Position< C, F, U > to_cartesian() const
Convert this spherical position to a cartesian Position<C,F,U>.
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Position< C, Target, U > > to_frame_with(const Time< TT, JD > &jd, const AstroContext &ctx) const
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Position< C, Target, U > > to_frame(const Time< TT, JD > &jd) const
Transform this position to a different reference frame (same center).