Browse Source

fix helixline's CPM

gjj
Zhicheng Wang 2 months ago
parent
commit
248ecbee27
  1. 11
      primitive_process/src/helixline.cpp

11
primitive_process/src/helixline.cpp

@ -1,4 +1,5 @@
#include <algorithm/glue_algorithm.hpp>
#include <limits>
#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<double>::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<double>::max()};
const auto alpha = this->total_theta * this->radius * r_p;

Loading…
Cancel
Save