From 56595a4c9cfad38a5fdd46d48e370edf70e0a079 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 7 Oct 2019 00:03:17 -0500 Subject: [PATCH] Improve G2/G3 precision See https://github.com/MarlinFirmware/Marlin/issues/14745#issuecomment-538781253 --- Marlin/src/gcode/motion/G2_G3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index e856afff1..5650e239b 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -287,7 +287,7 @@ void GcodeSuite::G2_G3(const bool clockwise) { const xy_pos_t d = p2 - p1, m = (p1 + p2) * 0.5f; // XY distance and midpoint const float e = clockwise ^ (r < 0) ? -1 : 1, // clockwise -1/1, counterclockwise 1/-1 len = d.magnitude(), // Total move length - h = SQRT(sq(r) - sq(len * 0.5f)); // Distance to the arc pivot-point + h = SQRT((r - d * 0.5f) * (r + d * 0.5f)); // Distance to the arc pivot-point const xy_pos_t s = { d.x, -d.y }; // Inverse Slope of the perpendicular bisector arc_offset = m + s * RECIPROCAL(len) * e * h - p1; // The calculated offset }