Skip to content

Commit

Permalink
Reduce division in JD calc (MarlinFirmware#17945)
Browse files Browse the repository at this point in the history
  • Loading branch information
XDA-Bam authored and vgadreau committed May 29, 2020
1 parent 54312d9 commit 6e6a183
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Marlin/src/module/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,12 @@ class Planner {

FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, xyze_float_t &unit_vec) {
float limit_value = max_value;
LOOP_XYZE(idx) if (unit_vec[idx]) // Avoid divide by zero
NOMORE(limit_value, ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]));
LOOP_XYZE(idx) {
if (unit_vec[idx]) {
if (limit_value * ABS(unit_vec[idx]) > settings.max_acceleration_mm_per_s2[idx])
limit_value = ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]);
}
}
return limit_value;
}

Expand Down

0 comments on commit 6e6a183

Please sign in to comment.