diff --git a/src/emc/rs274ngc/interp_arc.cc b/src/emc/rs274ngc/interp_arc.cc index 961f670e09c..65c526944ea 100644 --- a/src/emc/rs274ngc/interp_arc.cc +++ b/src/emc/rs274ngc/interp_arc.cc @@ -374,8 +374,8 @@ int Interp::arc_data_r(int move, //!< either G_2 (cw arc) or G_3 (ccw arc) half_length = hypot((mid_x - end_x), (mid_y - end_y)); CHKS(((half_length - abs_radius) > tolerance), NCE_ARC_RADIUS_TOO_SMALL_TO_REACH_END_POINT); - if ((half_length / abs_radius) > (1 - TINY)) - half_length = abs_radius; /* allow a small error for semicircle */ + if (half_length > abs_radius * (1 - TINY)) + abs_radius = half_length; /* allow a small error for semicircle, R0 too */ /* check needed before calling asin */ if (((move == G_2) && (radius > 0)) || ((move == G_3) && (radius < 0))) theta = atan2((end_y - current_y), (end_x - current_x)) - M_PI_2l; diff --git a/tests/interp/good/good-arc.r0.ngc b/tests/interp/good/good-arc.r0.ngc new file mode 100644 index 00000000000..9b653ebcf5e --- /dev/null +++ b/tests/interp/good/good-arc.r0.ngc @@ -0,0 +1,5 @@ +g21 +f1 +g0x0y0z0 +g2 x0.001 y0 r0 +m2 diff --git a/tests/interp/good/good-arc.r0.ngc.expected b/tests/interp/good/good-arc.r0.ngc.expected new file mode 100644 index 00000000000..d309d8275cd --- /dev/null +++ b/tests/interp/good/good-arc.r0.ngc.expected @@ -0,0 +1,19 @@ + 1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM) + 2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 4 N..... SET_XY_ROTATION(0.0000) + 5 N..... SET_FEED_REFERENCE(CANON_XYZ) + 6 N..... ON_RESET() + 7 N..... USE_LENGTH_UNITS(CANON_UNITS_MM) + 8 N..... SET_FEED_RATE(1.0000) + 9 N..... STRAIGHT_TRAVERSE(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 10 N..... ARC_FEED(0.0010, 0.0000, 0.0005, 0.0000, -1, 0.0000, 0.0000, 0.0000, 0.0000) + 11 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 12 N..... SET_XY_ROTATION(0.0000) + 13 N..... SET_FEED_MODE(0, 0) + 14 N..... SET_FEED_RATE(0.0000) + 15 N..... STOP_SPINDLE_TURNING(0) + 16 N..... SET_SPINDLE_MODE(0 0.0000) + 17 N..... PROGRAM_END() + 18 N..... ON_RESET() + 19 N..... ON_RESET()