From 54d6c251715389d61b0ca1a5c9039dbf7d3223d7 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 22 Dec 2025 17:13:04 +0300 Subject: [PATCH] ... --- mcc/mcc_angle.h | 11 +++++++ mcc/mcc_ccte_erfa.h | 12 +++++-- mcc/mcc_coord.h | 67 +++++++++++++++++++++++++++++++-------- mcc/mcc_generics.h | 2 ++ mcc/mcc_moving_controls.h | 4 +-- mcc/tests/ccte_test.cpp | 2 ++ 6 files changed, 80 insertions(+), 18 deletions(-) diff --git a/mcc/mcc_angle.h b/mcc/mcc_angle.h index b16fbef..e36f3aa 100644 --- a/mcc/mcc_angle.h +++ b/mcc/mcc_angle.h @@ -571,10 +571,21 @@ static constexpr bool mccIsObsCoordPairKind = (PK == MccCoordPairKind::COORDS_KIND_RADEC_OBS || PK == MccCoordPairKind::COORDS_KIND_HADEC_OBS || PK == MccCoordPairKind::COORDS_KIND_AZZD || PK == MccCoordPairKind::COORDS_KIND_AZALT); +static constexpr bool mcc_is_obs_coordpair(MccCoordPairKind kind) +{ + return kind == MccCoordPairKind::COORDS_KIND_RADEC_OBS || kind == MccCoordPairKind::COORDS_KIND_HADEC_OBS || + kind == MccCoordPairKind::COORDS_KIND_AZZD || kind == MccCoordPairKind::COORDS_KIND_AZALT; +}; + template static constexpr bool mccIsAppCoordPairKind = (PK == MccCoordPairKind::COORDS_KIND_RADEC_APP || PK == MccCoordPairKind::COORDS_KIND_HADEC_APP); +static constexpr bool mcc_is_app_coordpair(MccCoordPairKind kind) +{ + return kind == MccCoordPairKind::COORDS_KIND_RADEC_APP || kind == MccCoordPairKind::COORDS_KIND_HADEC_APP; +}; + static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_ICRS_STR = "RADEC-IRCS"; static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_APP_STR = "RADEC-APP"; diff --git a/mcc/mcc_ccte_erfa.h b/mcc/mcc_ccte_erfa.h index a7b99e7..ba55fbe 100644 --- a/mcc/mcc_ccte_erfa.h +++ b/mcc/mcc_ccte_erfa.h @@ -597,11 +597,17 @@ public: } else { // from apparent (2025-12-18: according to addition of RA/DEC_OCRS to mcc_eqt_hrz_coord_c) cpt.pair_kind = MccCoordPairKind::COORDS_KIND_RADEC_ICRS; ret = transformCoordinates(from_pt, &cpt); // to ICRS - if (!ret) { - ret = transformCoordinates(cpt, to_pt); + if (ret) { + return ret; } - return ret; + to_pt->RA_ICRS = cpt.X; + to_pt->DEC_ICRS = cpt.Y; + // if (!ret) { + // ret = transformCoordinates(cpt, to_pt); // from ICRS to observed + // } + + // return ret; } // from apparent: copy corresponded coordinates and compute other ones (ignore to_pt->pair_kind) diff --git a/mcc/mcc_coord.h b/mcc/mcc_coord.h index 06aaf3b..2a6f1d0 100644 --- a/mcc/mcc_coord.h +++ b/mcc/mcc_coord.h @@ -331,6 +331,10 @@ protected: template auto toHelper(PT& cpair) { + if (this == &cpair) { + return; + } + static constexpr double half_pi = std::numbers::pi / 2.0; // HA, DEC to AZ, ALT (AZ from the South through the West) @@ -387,34 +391,35 @@ protected: static_assert(PT::pairKind == MccCoordPairKind::COORDS_KIND_GENERIC, "UNSUPPORTED SKY POINT TRANSFORMATION!"); static_assert(PT::pairKind == MccCoordPairKind::COORDS_KIND_UNKNOWN, "UNSUPPORTED SKY POINT TRANSFORMATION!"); + // from ICRS to ICRS - just copy and exit if (_pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS && PT::pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { cpair = PT(PT::x_t(_x), PT::y_t(_y), _epoch); return; } + // just copy coordinates and exit if (_pairKind == PT::pairKind && utils::isEqual(_epoch.MJD(), cpair.MJD())) { cpair = PT(PT::x_t(_x), PT::y_t(_y), _epoch); return; } + + // if epochs is not the same then + // 1) convert stored coordinates to ICRS ones + // 2) convert from the computed ICRS coordinates to required ones MccCoordPairKind pkind = _pairKind; if (!utils::isEqual(_epoch.MJD(), cpair.MJD())) { // convert stored pair to ICRS one (ra_icrs, dec_icrs) if (_pairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { pkind = MccCoordPairKind::COORDS_KIND_RADEC_ICRS; - // convert here!!! - if (_pairKind == MccCoordPairKind::COORDS_KIND_RADEC_APP) { + + // cct_engine.appToICRS(app_type, app_x, app_y, ra_icrs, dec_icrs) + // cct_engine.obsToICRS(obs_type, obs_x, obs_y, ra_icrs, dec_icrs) + + if (mcc_is_obs_coordpair(_pairKind)) { + // cct_engine.obsToICRS(...) + } else if (mcc_is_app_coordpair(_pairKind)) { // cct_engine.appToICRS(...) - } else if (_pairKind == MccCoordPairKind::COORDS_KIND_RADEC_OBS) { - // cct_engine.obsToICRS(...) - } else if (_pairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP) { - // cct_engine.appToICRS(...) - } else if (_pairKind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) { - // cct_engine.obsToICRS(...) - } else if (_pairKind == MccCoordPairKind::COORDS_KIND_AZZD) { - // cct_engine.obsToICRS(...) - } else if (_pairKind == MccCoordPairKind::COORDS_KIND_AZALT) { - // cct_engine.obsToICRS(...) } else { // unsupported transformation!!! return; } @@ -424,14 +429,18 @@ protected: } } - // here, from APP or OBS to ICRS + // here, from APP or OBS to ICRS and exit if (pkind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS && PT::pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { cpair = PT(PT::x_t(ra_icrs), PT::y_t(dec_icrs), MccCelestialCoordEpoch{}); return; } + // here, the input coordinates and stored one are at the same epoch if (pkind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { + // cct_engine.icrsToObs(ra_icrs, dec_icrs, jd, ra_obs, dec_obs, ha, az, zd) + // cct_engine.icrsToApp(ra_icrs, dec_icrs, jd, ra_app, dec_app, ha) + if constexpr (mccIsObsCoordPairKind) { // cct_engine.icrsToObs(...) } else if constexpr (mccIsAppCoordPairKind) { @@ -538,6 +547,38 @@ protected: } else { // unsupported transformation!!! return; } + + if (pkind == MccCoordPairKind::COORDS_KIND_RADEC_APP || pkind == MccCoordPairKind::COORDS_KIND_RADEC_OBS) { + ra = _x; + dec = _y; + } else if (pkind == MccCoordPairKind::COORDS_KIND_HADEC_APP || + pkind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) { + ha = _x; + dec = _y; + } else if (pkind == MccCoordPairKind::COORDS_KIND_AZZD) { + az = _x; + zd = _y; + } else if (pkind == MccCoordPairKind::COORDS_KIND_AZALT) { + az = _x; + alt = _y; + } else { // unsupported transformation!!! + return; + } + + auto comp_func = [&, this](this auto& self, MccCoordPairKind cp_kind) { + if (cp_kind == MccCoordPairKind::COORDS_KIND_AZALT) { + if constexpr (PT::pairKind == MccCoordPairKind::COORDS_KIND_RADEC_APP) { + } else if constexpr (PT::pairKind == MccCoordPairKind::COORDS_KIND_RADEC_OBS) { + } else if constexpr (PT::pairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP) { + } else if constexpr (PT::pairKind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) { + } else if constexpr (PT::pairKind == MccCoordPairKind::COORDS_KIND_AZALT) { + } else { // unsupported transformation!!! + return; + } + } else if (cp_kind == MccCoordPairKind::COORDS_KIND_AZZD) { + alt = half_pi - _y; + } + }; } }; diff --git a/mcc/mcc_generics.h b/mcc/mcc_generics.h index a082ab4..1073158 100644 --- a/mcc/mcc_generics.h +++ b/mcc/mcc_generics.h @@ -613,6 +613,8 @@ concept mcc_telemetry_data_c = mcc_eqt_hrz_coord_c && std::default_initializa requires mcc_angle_c; }; + +// minimal library-wide telemetry data template concept mcc_tlm_data_c = mcc_eqt_hrz_coord_c && std::default_initializable && requires(T t) { // user entered target coordinates diff --git a/mcc/mcc_moving_controls.h b/mcc/mcc_moving_controls.h index 0566f8e..1942ba7 100644 --- a/mcc/mcc_moving_controls.h +++ b/mcc/mcc_moving_controls.h @@ -184,7 +184,7 @@ public: decltype([](typename MountT::mount_status_t) {})> MccSimpleMovingControls( MountT* mount, - CallbackFuncT&& mode_switch_calback = [](typename MountT::mount_status_t) {}) + CallbackFuncT&& mode_switch_callback = [](typename MountT::mount_status_t) {}) : _stopMoving(new std::atomic_bool), _currentParamsMutex(new std::mutex), _lastError(new std::atomic) { auto send_to_hardware = [mount](typename MountT::hardware_state_t const& hw_state) { @@ -309,7 +309,7 @@ public: *_lastError = MccSimpleMovingControlsErrorCode::ERROR_OK; using cb_func_t = std::function; - auto cb_sptr = std::shared_ptr(new cb_func_t(std::forward(mode_switch_calback))); + auto cb_sptr = std::shared_ptr(new cb_func_t(std::forward(mode_switch_callback))); /* stop moving function */ diff --git a/mcc/tests/ccte_test.cpp b/mcc/tests/ccte_test.cpp index b9594c8..71001ee 100644 --- a/mcc/tests/ccte_test.cpp +++ b/mcc/tests/ccte_test.cpp @@ -176,6 +176,8 @@ int main() // std::cout << "DEC_ICRS = " << mcc::MccAngle(cp.Y).sexagesimal() << "\n\n"; std::cout << "time point = " << eqhrz.time_point << "\n"; + std::cout << "RA_ICRS = " << mcc::MccAngle(eqhrz.RA_ICRS).sexagesimal(true) << "\n"; + std::cout << "DEC_ICRS = " << mcc::MccAngle(eqhrz.DEC_ICRS).sexagesimal() << "\n"; std::cout << "RA_APP = " << mcc::MccAngle(eqhrz.RA_APP).sexagesimal(true) << "\n"; std::cout << "DEC_APP = " << mcc::MccAngle(eqhrz.DEC_APP).sexagesimal() << "\n"; std::cout << "HA = " << mcc::MccAngle(eqhrz.HA).sexagesimal(true) << "\n";