This commit is contained in:
Timur A. Fatkhullin 2025-07-15 23:36:40 +03:00
parent 46e4b1e95f
commit 7e8d7eaa6b
2 changed files with 60 additions and 7 deletions

View File

@ -16,7 +16,7 @@
namespace mcc
{
static constexpr double mcc_UT1_to_sideral_ratio = 1.002737909350795; // UT1/sideral
static constexpr double mcc_sideral_to_UT1_ratio = 1.002737909350795; // sideral/UT1
/* SOME SIMPLE PROHIBITED ZONE IMPLEMENTATIONS */
@ -86,7 +86,13 @@ public:
return infDuration;
}
return compute(telemetry_data);
if constexpr (KIND ==
MccAltLimitKind::MIN_ALT_LIMIT) { // the closest time point is one after upper culmination
return compute(telemetry_data, false);
} else if constexpr (KIND == MccAltLimitKind::MAX_ALT_LIMIT) { // the closest time point is one before upper
// culmination
return compute(telemetry_data, true);
}
}
// returns a time to exit from the zone
@ -100,7 +106,13 @@ public:
return zeroDuration;
}
return compute(telemetry_data);
if constexpr (KIND ==
MccAltLimitKind::MIN_ALT_LIMIT) { // the closest time point is one before upper culmination
return compute(telemetry_data, true);
} else if constexpr (KIND == MccAltLimitKind::MAX_ALT_LIMIT) { // the closest time point is one after upper
// culmination
return compute(telemetry_data, false);
}
}
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
@ -174,7 +186,7 @@ private:
return true;
}
pz_duration_t compute(traits::mcc_mount_telemetry_data_c auto const& telemetry_data)
pz_duration_t compute(traits::mcc_mount_telemetry_data_c auto const& telemetry_data, bool before_upper_culm)
{
double cos_ha = (std::sin(_altLimit) - std::sin(telemetry_data.mntDEC) * std::sin(_latitude)) /
std::cos(telemetry_data.mntDEC) / std::cos(_latitude);
@ -183,12 +195,31 @@ private:
return infDuration;
}
MccAngle time_ang = std::acos(cos_ha) - telemetry_data.mntHA; // in sideral time scale
if (time_ang < 0.0) { // next day
double ha;
if (before_upper_culm) {
ha = -std::acos(cos_ha); // HA before upper culmination
} else {
ha = std::acos(cos_ha); // HA after upper culmination!!
}
// if constexpr (KIND == MccAltLimitKind::MIN_ALT_LIMIT) { // the closest time moment after upper
// culmination!!!
// ha = std::acos(cos_ha); // HA after upper culmination!!
// } else if constexpr (KIND ==
// MccAltLimitKind::MAX_ALT_LIMIT) { // the closest time moment before upper
// culmination!!!
// ha = -std::acos(cos_ha); // HA before upper culmination
// } else {
// static_assert(false, "UNKNOWN ALTITUDE LIMIT TYPE!");
// }
MccAngle time_ang = ha - telemetry_data.mntHA; // in sideral time scale
if (time_ang < 0.0) { // next day
time_ang += pi2;
}
time_ang *= mcc_UT1_to_sideral_ratio;
time_ang /= mcc_sideral_to_UT1_ratio; // to UT1 time scale
return pz_duration_t{time_ang.seconds()};
}

View File

@ -219,6 +219,14 @@ int main(int argc, char* argv[])
std::cout << "(MINALT) time to zone: " << std::chrono::hh_mm_ss(tm) << " (" << now1 << ")\n";
}
tm = minalt_pz.timeFrom(tdata);
if (std::isinf(tm.count())) {
std::cout << "(MINALT) time from zone: the object never reaches the zone!\n";
} else {
auto now1 = now + std::chrono::duration_cast<decltype(now)::duration>(tm);
std::cout << "(MINALT) time from zone: " << std::chrono::hh_mm_ss(tm) << " (" << now1 << ")\n";
}
std::cout << "\n";
ra1 = "17:00:00"_hms;
@ -235,13 +243,27 @@ int main(int argc, char* argv[])
tdata = {ra_o, dec_o, ha1, az1, alt1, 0.0, 0.0};
jd.mjd += 1.0;
res = erfa.icrs2obs(ra1, dec1, jd, ra_o, dec_o, ha1, az1, alt1, eor);
std::cout << "RA_app (+24h) = " << ra_o.sexagesimal(true) << "\n";
tm = maxalt_pz.timeTo(tdata);
if (std::isinf(tm.count())) {
std::cout << "(MAXALT) time to zone: the object never reaches the zone!\n";
} else {
// auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(tm);
auto now1 = now + std::chrono::duration_cast<decltype(now)::duration>(tm);
// auto now1 = now + ns;
std::cout << "(MAXALT) time to zone: " << std::chrono::hh_mm_ss(tm) << " (" << now1 << ")\n";
}
tm = maxalt_pz.timeFrom(tdata);
if (std::isinf(tm.count())) {
std::cout << "(MAXALT) time from zone: the object never reaches the zone!\n";
} else {
auto now1 = now + std::chrono::duration_cast<decltype(now)::duration>(tm);
std::cout << "(MAXALT) time from zone: " << std::chrono::hh_mm_ss(tm) << " (" << now1 << ")\n";
}
return ecode;
}