Fix for G2/G3 rounding error (#15546)
This commit is contained in:
parent
92754080f3
commit
9468669981
|
@ -3525,7 +3525,8 @@ inline void gcode_G0_G1(
|
||||||
const float e = clockwise ^ (r < 0) ? -1 : 1, // clockwise -1/1, counterclockwise 1/-1
|
const float e = clockwise ^ (r < 0) ? -1 : 1, // clockwise -1/1, counterclockwise 1/-1
|
||||||
dx = p2 - p1, dy = q2 - q1, // X and Y differences
|
dx = p2 - p1, dy = q2 - q1, // 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.5f)), // Distance to the arc pivot-point
|
h2 = (r - 0.5f * d) * (r + 0.5f * d), // factor to reduce rounding error
|
||||||
|
h = (h2 >= 0) ? SQRT(h2) : 0.0f, // Distance to the arc pivot-point
|
||||||
mx = (p1 + p2) * 0.5f, my = (q1 + q2) * 0.5f, // Point between the two points
|
mx = (p1 + p2) * 0.5f, my = (q1 + q2) * 0.5f, // Point between the two points
|
||||||
sx = -dy / d, sy = dx / d, // Slope of the perpendicular bisector
|
sx = -dy / d, sy = dx / d, // Slope of the perpendicular bisector
|
||||||
cx = mx + e * h * sx, cy = my + e * h * sy; // Pivot-point of the arc
|
cx = mx + e * h * sx, cy = my + e * h * sy; // Pivot-point of the arc
|
||||||
|
|
Loading…
Reference in New Issue