Browse Source

Fix vector normalization in JD (#17938)

XDA-Bam 4 years ago
parent
commit
3381a4ab03
No account linked to committer's email address
1 changed files with 10 additions and 9 deletions
  1. 10
    9
      Marlin/src/module/planner.cpp

+ 10
- 9
Marlin/src/module/planner.cpp View File

@@ -2256,16 +2256,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2256 2256
         { steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.e }
2257 2257
       #endif
2258 2258
     ;
2259
-    unit_vec *= inverse_millimeters;
2260 2259
 
2261
-    #if IS_CORE && HAS_JUNCTION_DEVIATION
2262
-      /**
2263
-       * On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y].
2264
-       * So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters".
2265
-       * => normalize the complete junction vector
2266
-       */
2267
-      normalize_junction_vector(unit_vec);
2268
-    #endif
2260
+    /**
2261
+     * On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y].
2262
+     * So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters".
2263
+     * => normalize the complete junction vector.
2264
+     * Elsewise, when needed JD factors in the E component
2265
+     */
2266
+    if (ENABLED(IS_CORE) || esteps > 0)
2267
+      normalize_junction_vector(unit_vec);  // Normalize with XYZE components
2268
+    else
2269
+      unit_vec *= inverse_millimeters;      // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2))
2269 2270
 
2270 2271
     // Skip first block or when previous_nominal_speed is used as a flag for homing and offset cycles.
2271 2272
     if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) {

Loading…
Cancel
Save