Skip to content

Commit

Permalink
Improve G2/G3 precision
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 7, 2019
1 parent 211ff67 commit 56595a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Marlin/src/gcode/motion/G2_G3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

1 comment on commit 56595a4

@edwilliams16
Copy link
Contributor

@edwilliams16 edwilliams16 commented on 56595a4 Oct 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thinkyhead
h = SQRT((r - d * 0.5f) * (r + d * 0.5f));

shouldn't this be
h = SQRT((r - len * 0.5f) * (r + len * 0.5f));

I'm not sure what it does using d It looks illegal.

Also, I believe
const xy_pos_t s = { d.x, -d.y }; // Inverse slope of the perpendicular bisector
should be
const xy_pos_t s = { -d.y, d.x }; // move rotated 90 degrees

The above error was introduced in the refactoring #15204

Please sign in to comment.