1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 20:18:52 +00:00

Fix for G2/G3 negative radius

As suggested in #4940
This commit is contained in:
Scott Lahteine 2016-10-03 14:48:44 -05:00 committed by GitHub
parent d5f598cd82
commit 5c1eb595e6

View File

@ -2796,7 +2796,7 @@ inline void gcode_G0_G1(
x1 = current_position[X_AXIS], y1 = current_position[Y_AXIS], x1 = current_position[X_AXIS], y1 = current_position[Y_AXIS],
x2 = destination[X_AXIS], y2 = destination[Y_AXIS]; x2 = destination[X_AXIS], y2 = destination[Y_AXIS];
if (r && (x2 != x1 || y2 != y1)) { if (r && (x2 != x1 || y2 != y1)) {
const float e = clockwise ? -1 : 1, // clockwise -1, counterclockwise 1 const float e = clockwise ^ (r < 0) ? -1 : 1, // clockwise -1/1, counterclockwise 1/-1
dx = x2 - x1, dy = y2 - y1, // X and Y differences dx = x2 - x1, dy = y2 - y1, // X and Y differences
d = HYPOT(dx, dy), // Linear distance between the points d = HYPOT(dx, dy), // Linear distance between the points
h = sqrt(sq(r) - sq(d * 0.5)), // Distance to the arc pivot-point h = sqrt(sq(r) - sq(d * 0.5)), // Distance to the arc pivot-point