From 9315018bda738c5b3fc46f847a3080f1a86046d2 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 21 Apr 2025 18:42:21 +0300 Subject: [PATCH] rename MccCoordinate to MccAngle --- cxx/mcc_coord.h | 68 +++++++++++++++++++-------------------- cxx/mount.h | 28 ++++++++-------- cxx/mount_astrom.h | 14 ++++---- cxx/mount_pz.h | 32 +++++++++--------- cxx/tests/astrom_test.cpp | 4 +-- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/cxx/mcc_coord.h b/cxx/mcc_coord.h index ddc14fd..14f55b2 100644 --- a/cxx/mcc_coord.h +++ b/cxx/mcc_coord.h @@ -55,7 +55,7 @@ static constexpr MccHMSTag mcc_hms{}; // coordinate representation class -class MccCoordinate +class MccAngle { protected: double _angleInRads{0.0}; @@ -68,25 +68,25 @@ public: NORM_KIND_90_90, // [-90,90] }; - MccCoordinate() = default; + MccAngle() = default; // by default angle is in radians - MccCoordinate(std::convertible_to auto const& val, const MccRadianTag tag = MccRadianTag{}) + MccAngle(std::convertible_to auto const& val, const MccRadianTag tag = MccRadianTag{}) : _angleInRads(val) { } // construct angle in degrees, e.g.: - // auto ang = MccCoordinate{180.0, mcc_degrees}; - MccCoordinate(std::convertible_to auto const& val, const MccDegreeTag tag) + // auto ang = MccAngle{180.0, mcc_degrees}; + MccAngle(std::convertible_to auto const& val, const MccDegreeTag tag) { _angleInRads = val * utils::deg2radCoeff; } // constuct angle from sexagesimal representation or floating-point number of degrees, e.g.: - // auto ang = MccCoordinate{"-12:34:56.789"}; // from degrees:minutes:seconds - // auto ang = MccCoordinate{"123.574698"}; // from degrees - MccCoordinate(traits::mcc_input_char_range auto const& val) + // auto ang = MccAngle{"-12:34:56.789"}; // from degrees:minutes:seconds + // auto ang = MccAngle{"123.574698"}; // from degrees + MccAngle(traits::mcc_input_char_range auto const& val) { auto res = utils::parsAngleString(val); if (res.has_value()) { @@ -97,9 +97,9 @@ public: } // construct angle from sexagesimal representation or floating-point number of degrees, e.g.: - // auto ang = MccCoordinate{"01:23:45.6789", mcc_hms}; // from hours:minutes:seconds - // auto ang = MccCoordinate{"123.574698"}; // from degrees - MccCoordinate(traits::mcc_input_char_range auto const& val, const MccHMSTag) + // auto ang = MccAngle{"01:23:45.6789", mcc_hms}; // from hours:minutes:seconds + // auto ang = MccAngle{"123.574698"}; // from degrees + MccAngle(traits::mcc_input_char_range auto const& val, const MccHMSTag) { auto res = utils::parsAngleString(val, true); if (res.has_value()) { @@ -109,11 +109,11 @@ public: } } - virtual ~MccCoordinate() = default; + virtual ~MccAngle() = default; // normalize coordinate template - MccCoordinate& normalize() + MccAngle& normalize() { _angleInRads = std::fmod(_angleInRads, std::numbers::pi * 2.0); @@ -142,7 +142,7 @@ public: return *this; } - MccCoordinate& normalize() + MccAngle& normalize() { return normalize(); } @@ -175,68 +175,68 @@ public: return sexagesimal(hms, prec); } - friend MccCoordinate operator+(std::convertible_to auto&& left, - std::convertible_to auto&& right) + friend MccAngle operator+(std::convertible_to auto&& left, + std::convertible_to auto&& right) { // return std::forward(left)._angleInRads + // std::forward(right)._angleInRads; - return MccCoordinate{std::forward(left)}._angleInRads + - MccCoordinate{std::forward(right)}._angleInRads; + return MccAngle{std::forward(left)}._angleInRads + + MccAngle{std::forward(right)}._angleInRads; } - // friend MccCoordinate operator+(const MccCoordinate& left, const MccCoordinate& right) + // friend MccAngle operator+(const MccAngle& left, const MccAngle& right) // { // return left._angleInRads + right._angleInRads; // } - friend MccCoordinate operator-(std::convertible_to auto&& left, - std::convertible_to auto&& right) + friend MccAngle operator-(std::convertible_to auto&& left, + std::convertible_to auto&& right) { // return std::forward(left)._angleInRads - // std::forward(right)._angleInRads; - return MccCoordinate{std::forward(left)}._angleInRads - - MccCoordinate{std::forward(right)}._angleInRads; + return MccAngle{std::forward(left)}._angleInRads - + MccAngle{std::forward(right)}._angleInRads; } - // friend MccCoordinate operator-(const MccCoordinate& left, const MccCoordinate& right) + // friend MccAngle operator-(const MccAngle& left, const MccAngle& right) // { // return left._angleInRads + right._angleInRads; // } template - MccCoordinate operator*(T&& scalar) + MccAngle operator*(T&& scalar) requires std::is_arithmetic_v> { return _angleInRads * scalar; } template - MccCoordinate operator/(T&& scalar) + MccAngle operator/(T&& scalar) requires std::is_arithmetic_v> { return _angleInRads / scalar; } template - MccCoordinate operator-() // unary '-' + MccAngle operator-() // unary '-' requires std::is_arithmetic_v> { return -_angleInRads; } - MccCoordinate& operator+=(const MccCoordinate& v) + MccAngle& operator+=(const MccAngle& v) { _angleInRads += v._angleInRads; return *this; } - MccCoordinate& operator-=(const MccCoordinate& v) + MccAngle& operator-=(const MccAngle& v) { _angleInRads += v._angleInRads; return *this; } template - MccCoordinate& operator*=(T&& scalar) + MccAngle& operator*=(T&& scalar) requires std::is_arithmetic_v> { _angleInRads *= scalar; @@ -244,19 +244,19 @@ public: } template - MccCoordinate& operator/=(T&& scalar) + MccAngle& operator/=(T&& scalar) requires std::is_arithmetic_v> { _angleInRads /= scalar; return *this; } - auto operator<=>(const MccCoordinate& other) const + auto operator<=>(const MccAngle& other) const { return _angleInRads <=> other._angleInRads; } - auto operator==(const MccCoordinate& other) const + auto operator==(const MccAngle& other) const { return _angleInRads == other._angleInRads; } @@ -279,7 +279,7 @@ enum class MccNormCoordKind { }; template -class MccNormCoordinate : public MccCoordinate +class MccNormCoordinate : public MccAngle { public: static constexpr MccNormCoordKind normKind = KIND; diff --git a/cxx/mount.h b/cxx/mount.h index 86a3cec..98717fa 100644 --- a/cxx/mount.h +++ b/cxx/mount.h @@ -254,7 +254,7 @@ public: _geoLocation.store(geoloc); } - void setSiteLatitude(const MccCoordinate& lat) + void setSiteLatitude(const MccAngle& lat) { auto st = _geoLocation.load(); st.latitude = lat; @@ -262,7 +262,7 @@ public: _geoLocation.store(st); } - void setSiteLongitude(const MccCoordinate& lon) + void setSiteLongitude(const MccAngle& lon) { auto st = _geoLocation.load(); st.longitude = lon; @@ -330,8 +330,8 @@ public: // 0 - already in the zone // std::chrono::duration<>::max() - never reach the zone // the kind of cordinates (e.g. IRCS or apparent, equatorial or horizontal) is a subject of implementation - auto pzTimeTo(const MccCoordinate& xcoord, - const MccCoordinate& ycoord, + auto pzTimeTo(const MccAngle& xcoord, + const MccAngle& ycoord, traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now()) { using d_t = std::remove_cvref_t::duration; @@ -343,8 +343,8 @@ public: // 0 - already out of the zone // std::chrono::duration<>::max() - the zone itself // the kind of cordinates (e.g. IRCS or apparent, equatorial or horizontal) is a subject of implementation - auto pzTimeFrom(const MccCoordinate& xcoord, - const MccCoordinate& ycoord, + auto pzTimeFrom(const MccAngle& xcoord, + const MccAngle& ycoord, traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now()) { using d_t = std::remove_cvref_t::duration; @@ -360,8 +360,8 @@ public: // never exit the zone) auto pzCheck(this auto&& self, - const MccCoordinate& xcoord, - const MccCoordinate& ycoord, + const MccAngle& xcoord, + const MccAngle& ycoord, std::derived_from auto const& context, traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now()) { @@ -373,8 +373,8 @@ public: const R2& ycoord, std::derived_from auto const& context) requires(std::ranges::output_range> && - std::derived_from, MccCoordinate> && - std::derived_from, MccCoordinate>) + std::derived_from, MccAngle> && + std::derived_from, MccAngle>) { OR res; @@ -390,8 +390,8 @@ public: auto pzCheckRange(const R1& xcoord, const R2& ycoord, std::derived_from auto const& context) - requires(std::derived_from, MccCoordinate> && - std::derived_from, MccCoordinate>) + requires(std::derived_from, MccAngle> && + std::derived_from, MccAngle>) { return pzCheckRange>>(xcoord, ycoord, context); } @@ -445,8 +445,8 @@ protected: std::atomic _currentMeteo; // default implementation - auto pzCheckImpl(const MccCoordinate& xcoord, - const MccCoordinate& ycoord, + auto pzCheckImpl(const MccAngle& xcoord, + const MccAngle& ycoord, std::derived_from auto const& context, traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now()) { diff --git a/cxx/mount_astrom.h b/cxx/mount_astrom.h index d8cc8f9..3119e5b 100644 --- a/cxx/mount_astrom.h +++ b/cxx/mount_astrom.h @@ -169,11 +169,11 @@ static int mcc_julday(traits::mcc_systime_c auto const& start_time, * .second = time duration to reach given altitude AFTER object upper culmination */ std::pair, std::chrono::duration> mcc_time_to_alt( - const MccCoordinate& alt_limit, - const MccCoordinate& ra, - const MccCoordinate& dec, - const MccCoordinate& lat, - const MccCoordinate& lon, + const MccAngle& alt, + const MccAngle& ra, + const MccAngle& dec, + const MccAngle& lat, + const MccAngle& lon, traits::mcc_systime_c auto const& now, traits::mcc_time_duration_c auto const& dut1, // UT1-UTC traits::mcc_time_duration_c auto const& tt_tai, // TT-TAI @@ -183,7 +183,7 @@ std::pair, std::chrono::duration> mcc_time auto nan_dur = std::chrono::duration(std::numeric_limits::quiet_NaN()); auto inf_dur = std::chrono::duration(std::numeric_limits::infinity()); - if (alt_limit < 0.0) { + if (alt < 0.0) { return {nan_dur, nan_dur}; } @@ -197,7 +197,7 @@ std::pair, std::chrono::duration> mcc_time } } - double cos_ha = (std::sin(alt_limit) - std::sin(dec) * std::sin(lat)) / std::cos(dec) / std::cos(lat); + double cos_ha = (std::sin(alt) - std::sin(dec) * std::sin(lat)) / std::cos(dec) / std::cos(lat); if (std::abs(cos_ha) > 1.0) { // it never reach given altitude return {inf_dur, inf_dur}; } diff --git a/cxx/mount_pz.h b/cxx/mount_pz.h index 58cbe68..b0a1a98 100644 --- a/cxx/mount_pz.h +++ b/cxx/mount_pz.h @@ -17,14 +17,14 @@ concept mcc_prohibited_zone_c = requires(T t, const T const_t) { // check if given coordinates are within the zone { - t.inZone(std::declval(), std::declval(), + t.inZone(std::declval(), std::declval(), std::declval()) } -> std::convertible_to; // a time duration to reach the zone (0 - if already in the zone, chrono::duration<>::max() if never // reach the zone) { - t.timeTo(std::declval(), std::declval(), + t.timeTo(std::declval(), std::declval(), std::declval(), std::declval()) } -> mcc_time_duration_c; @@ -32,7 +32,7 @@ concept mcc_prohibited_zone_c = requires(T t, const T const_t) { // a time duration to exit the zone (0 - if already out of the zone, chrono::duration<>::max() if // never exit the zone) { - t.timeFrom(std::declval(), std::declval(), + t.timeFrom(std::declval(), std::declval(), std::declval(), std::declval()) } -> mcc_time_duration_c; @@ -46,13 +46,13 @@ class MccProhibitedZone public: virtual ~MccProhibitedZone() = default; - bool inZone(this auto&& self, const MccCoordinate& x, const MccCoordinate& y) + bool inZone(this auto&& self, const MccAngle& x, const MccAngle& y) { return std::forward(self).inZoneImpl(x, y); } protected: - bool inZoneImpl(const MccCoordinate&, const MccCoordinate&) + bool inZoneImpl(const MccAngle&, const MccAngle&) { return false; } @@ -61,9 +61,9 @@ protected: class MccMinAltPZ : public MccProhibitedZone { public: - MccMinAltPZ(const MccCoordinate& min_alt) : _minAlt(min_alt) {} + MccMinAltPZ(const MccAngle& min_alt) : _minAlt(min_alt) {} - MccCoordinate minAlt() const + MccAngle minAlt() const { return _minAlt; } @@ -71,7 +71,7 @@ public: private: double _minAlt; - bool inZoneImpl(const MccCoordinate& alt, const MccCoordinate&) + bool inZoneImpl(const MccAngle& alt, const MccAngle&) { return alt <= _minAlt; } @@ -91,7 +91,7 @@ public: private: double _maxAlt; - bool inZoneImpl(const MccCoordinate& alt, const MccCoordinate&) + bool inZoneImpl(const MccAngle& alt, const MccAngle&) { return alt >= _maxAlt; } @@ -139,11 +139,11 @@ private: class MccEllipsePZ { public: - MccEllipsePZ(const MccCoordinate& xc, - const MccCoordinate& yc, - const MccCoordinate& a, - const MccCoordinate& b, - const MccCoordinate& theta = 0.0) + MccEllipsePZ(const MccAngle& xc, + const MccAngle& yc, + const MccAngle& a, + const MccAngle& b, + const MccAngle& theta = 0.0) : _xc(xc), _yc(yc), _a(a), _b(b), _theta(theta), _tanXc(std::tan(xc)), _tanYc(std::tan(yc)) { _tanYc *= std::sqrt(1.0 + _tanXc * _tanXc); @@ -168,7 +168,7 @@ public: } // circle - MccEllipsePZ(const MccCoordinate& xc, const MccCoordinate& yc, const MccCoordinate& a) + MccEllipsePZ(const MccAngle& xc, const MccAngle& yc, const MccAngle& a) : mcc::MccEllipsePZ(xc, yc, a, a) { } @@ -178,7 +178,7 @@ private: double _xc, _yc, _a, _b, _theta; double _tanXc, _tanYc, cxx, cxy, cyy; - bool inZoneImpl(const MccCoordinate& x, const MccCoordinate& y) + bool inZoneImpl(const MccAngle& x, const MccAngle& y) { auto tanX = tan(x); auto tanY = tan(y) * sqrt(1.0 + tanX * tanX); diff --git a/cxx/tests/astrom_test.cpp b/cxx/tests/astrom_test.cpp index 814fa7e..38bba03 100644 --- a/cxx/tests/astrom_test.cpp +++ b/cxx/tests/astrom_test.cpp @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) std::cout << "\n\n\nMccCoordinate class test:\n"; - mcc::MccCoordinate ra("12:00:00", mcc::mcc_hms); + mcc::MccAngle ra("12:00:00", mcc::mcc_hms); std::cout << "sin(12h) = " << std::sin(ra) << "\n"; std::cout << "cos(12h) = " << std::cos(ra) << "\n"; @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) std::cout << "sin(18h) = " << std::sin(ra) << "\n"; std::cout << "cos(18h) = " << std::cos(ra) << "\n"; - ra = mcc::MccCoordinate{45.0, mcc::mcc_degrees}; + ra = mcc::MccAngle{45.0, mcc::mcc_degrees}; std::cout << "sin(45) = " << std::sin(ra) << "\n"; std::cout << "cos(45) = " << std::cos(ra) << "\n";