From 18669735322e6861f02f0e547994860d4132e726 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 11 Apr 2023 09:12:48 +0200 Subject: [PATCH] refactor(example): `get_length()` renamed to `get_distance()` --- example/glide_computer/glide_computer.cpp | 10 +++++----- example/glide_computer/include/glide_computer.h | 4 ++-- example/glide_computer_example.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/example/glide_computer/glide_computer.cpp b/example/glide_computer/glide_computer.cpp index 25cef4c2..3d1b1f6c 100644 --- a/example/glide_computer/glide_computer.cpp +++ b/example/glide_computer/glide_computer.cpp @@ -43,7 +43,7 @@ std::vector task::make_leg_total_distances(const legs& legs) { std::vector res; res.reserve(legs.size()); - auto to_length = [](const leg& l) { return l.get_length(); }; + auto to_length = [](const leg& l) { return l.get_distance(); }; std::transform_inclusive_scan(legs.cbegin(), legs.cend(), std::back_inserter(res), std::plus(), to_length); return res; } @@ -52,7 +52,7 @@ altitude terrain_level_alt(const task& t, const flight_point& pos) { const task::leg& l = t.get_legs()[pos.leg_idx]; const height alt_diff = l.end().alt - l.begin().alt; - return l.begin().alt + alt_diff * ((pos.dist - t.get_leg_dist_offset(pos.leg_idx)) / l.get_length()); + return l.begin().alt + alt_diff * ((pos.dist - t.get_leg_dist_offset(pos.leg_idx)) / l.get_distance()); } // Returns `x` of the intersection of a glide line and a terrain line. @@ -60,7 +60,7 @@ altitude terrain_level_alt(const task& t, const flight_point& pos) // y = (finish_alt - ground_alt) / dist_to_finish * x + ground_alt + min_agl_height; distance glide_distance(const flight_point& pos, const glider& g, const task& t, const safety& s, altitude ground_alt) { - const auto dist_to_finish = t.get_length() - pos.dist; + const auto dist_to_finish = t.get_distance() - pos.dist; return quantity_cast(ground_alt + s.min_agl_height - pos.alt) / ((ground_alt - t.get_finish().alt) / dist_to_finish - 1 / glide_ratio(g.polar[0])); } @@ -124,7 +124,7 @@ flight_point glide(timestamp start_ts, const flight_point& pos, const glider& g, flight_point final_glide(timestamp start_ts, const flight_point& pos, const glider& g, const task& t) { - const auto dist = t.get_length() - pos.dist; + const auto dist = t.get_distance() - pos.dist; const auto l3d = length_3d(dist, pos.alt - t.get_finish().alt); const duration d = l3d / g.polar[0].v; const flight_point new_pos{pos.ts + d, t.get_finish().alt, t.get_legs().size() - 1, pos.dist + dist}; @@ -152,7 +152,7 @@ void estimate(timestamp start_ts, const glider& g, const weather& w, const task& // estimate the altitude needed to reach the finish line from this place const altitude final_glide_alt = - t.get_finish().alt + quantity_cast(t.get_length()) / glide_ratio(g.polar[0]); + t.get_finish().alt + quantity_cast(t.get_distance() / glide_ratio(g.polar[0])); // how much height we still need to gain in the thermalls to reach the destination? height height_to_gain = final_glide_alt - pos.alt; diff --git a/example/glide_computer/include/glide_computer.h b/example/glide_computer/include/glide_computer.h index ed34024c..ad28d604 100644 --- a/example/glide_computer/include/glide_computer.h +++ b/example/glide_computer/include/glide_computer.h @@ -133,7 +133,7 @@ public: leg(const waypoint& b, const waypoint& e) noexcept : begin_(&b), end_(&e) {} constexpr const waypoint& begin() const { return *begin_; }; constexpr const waypoint& end() const { return *end_; } - constexpr distance get_length() const { return length_; } + constexpr distance get_distance() const { return length_; } }; using legs = std::vector; @@ -151,7 +151,7 @@ public: const waypoint& get_start() const { return waypoints_.front(); } const waypoint& get_finish() const { return waypoints_.back(); } - distance get_length() const { return length_; } + distance get_distance() const { return length_; } distance get_leg_dist_offset(std::size_t leg_index) const { diff --git a/example/glide_computer_example.cpp b/example/glide_computer_example.cpp index 0ef2dfd9..88184977 100644 --- a/example/glide_computer_example.cpp +++ b/example/glide_computer_example.cpp @@ -126,12 +126,12 @@ void print(const task& t) std::cout << "- Start: " << t.get_start().name << "\n"; std::cout << "- Finish: " << t.get_finish().name << "\n"; - std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n"; + std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_distance()) << "\n"; std::cout << "- Legs: " << "\n"; for (const auto& l : t.get_legs()) - std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length()); + std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_distance()); std::cout << "\n"; }