From b8947ac8a5182b6b54165fb6ddc4177efb32091a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 May 2020 15:13:37 -0500 Subject: [PATCH] More explicit junction/jerk math --- Marlin/src/module/planner.cpp | 6 +++--- Marlin/src/module/planner.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index bb9e7b92fe..6d2a0edc31 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2304,7 +2304,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec), sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. - vmax_junction_sqr = JUNC_SQ(junction_acceleration, sin_theta_d2); + vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); if (block->millimeters < 1) { const float neg = junction_cos_theta < 0 ? -1 : 1, @@ -2340,8 +2340,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, * for (float t = 0; t <= 1; t += 0.0003f) { * const float e = acos(t) / approx(t); * if (isfinite(e)) { - * NOMORE(min, e); - * NOLESS(max, e); + * if (e < min) min = e; + * if (e > max) max = e; * } * } * fprintf(stderr, "%.9gf, ", (min + max) / 2); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index ccc7faf706..05c5c44cee 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -838,11 +838,9 @@ class Planner { static void autotemp_update(); #endif - #define JUNC_SQ(N,ST) (junction_deviation_mm * (N) * (ST) / (1.0f - (ST))) - #if HAS_LINEAR_E_JERK FORCE_INLINE static void recalculate_max_e_jerk() { - #define GET_MAX_E_JERK(N) SQRT(JUNC_SQ(N,SQRT(0.5))) + #define GET_MAX_E_JERK(N) SQRT(junction_deviation_mm * (N) * SQRT(0.5) / (1.0f - SQRT(0.5))) #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(i, EXTRUDERS) max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);