From 248ecbee27481447339392582bd40822f0b0ac75 Mon Sep 17 00:00:00 2001 From: Zhicheng Wang <1627343141@qq.com> Date: Sun, 12 Jan 2025 16:34:56 +0800 Subject: [PATCH] fix helixline's CPM --- primitive_process/src/helixline.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/primitive_process/src/helixline.cpp b/primitive_process/src/helixline.cpp index f520278..b6f6fb9 100644 --- a/primitive_process/src/helixline.cpp +++ b/primitive_process/src/helixline.cpp @@ -1,4 +1,5 @@ #include +#include #include "internal_primitive_desc.hpp" @@ -124,7 +125,6 @@ helixline::helixline(helixline_descriptor_t struct line_simple_distance_param_t { double t{}; - bool need_refine{false}; bool is_peak_value{true}; } peak_value_param{}; @@ -160,17 +160,18 @@ helixline::helixline(helixline_descriptor_t bool increasing_flag = (f0 > 0 && f1 > 0); bool decreasing_flag = (f0 < 0 && f1 < 0); // i.e. has a root t=t0, or distance is always increasing as t increases - if ((f0 >= -EPSILON && f0 <= EPSILON) || increasing_flag) return {t0, false, !increasing_flag}; + if ((f0 >= -EPSILON && f0 <= EPSILON) || increasing_flag) return {t0, !increasing_flag}; // i.e. has a root t=t1, or distance is always decreasing as t increases - if ((f1 >= -EPSILON && f1 <= EPSILON) || decreasing_flag) return {t1, false, !decreasing_flag}; + if ((f1 >= -EPSILON && f1 <= EPSILON) || decreasing_flag) return {t1, !decreasing_flag}; // i.e. has a root t in (0, 1) // in this case, we use linear interpolation as a guess - return {f0 / (f0 - f1), true, true}; + if (f0 < -EPSILON && f1 > EPSILON) return {f0 / (f0 - f1), true}; + return {std::numeric_limits::max(), false}; }); } // if we need to refine the guess, just do it!!! - if (peak_value_param.need_refine) { + { auto &t = peak_value_param.t; double delta_t{std::numeric_limits::max()}; const auto alpha = this->total_theta * this->radius * r_p;