From 1fd8e2c6492bff0448450303ebf544f1bd89f064 Mon Sep 17 00:00:00 2001 From: HackingGulliver Date: Sat, 12 Jan 2019 02:25:48 +0100 Subject: [PATCH] Fix: Junction Deviation calculates wrong cos(theta) on CoreXY (#12879) --- Marlin/src/module/planner.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8de2db5c06..c111df7b95 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2392,6 +2392,15 @@ bool Planner::_populate_block(block_t * const block, bool split_move, }; #endif + #if IS_CORE && ENABLED(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 + // 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)) { // Compute cosine of angle between previous and current path. (prev_unit_vec is negative)