From 3381a4ab0322af75124e920e61840c7a753ffadf Mon Sep 17 00:00:00 2001 From: XDA-Bam <1209896+XDA-Bam@users.noreply.github.com> Date: Mon, 11 May 2020 08:06:35 +0200 Subject: [PATCH] Fix vector normalization in JD (#17938) --- Marlin/src/module/planner.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 9c1071c6fb39..7d23789df1f7 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2256,16 +2256,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move, { steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.e } #endif ; - unit_vec *= inverse_millimeters; - #if IS_CORE && HAS_JUNCTION_DEVIATION - /** - * On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y]. - * So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters". - * => normalize the complete junction vector - */ - normalize_junction_vector(unit_vec); - #endif + /** + * On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y]. + * So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters". + * => normalize the complete junction vector. + * Elsewise, when needed JD factors in the E component + */ + if (ENABLED(IS_CORE) || esteps > 0) + normalize_junction_vector(unit_vec); // Normalize with XYZE components + else + unit_vec *= inverse_millimeters; // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2)) // Skip first block or when previous_nominal_speed is used as a flag for homing and offset cycles. if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) {