Simpler Allen Key config. Fixes, cleanups from refactor (#15256)
This commit is contained in:
		@@ -280,20 +280,22 @@ void GcodeSuite::G2_G3(const bool clockwise) {
 | 
			
		||||
 | 
			
		||||
    float arc_offset[2] = { 0, 0 };
 | 
			
		||||
    if (parser.seenval('R')) {
 | 
			
		||||
      const float r = parser.value_linear_units(),
 | 
			
		||||
                  p1 = current_position[X_AXIS], q1 = current_position[Y_AXIS],
 | 
			
		||||
                  p2 = destination[X_AXIS], q2 = destination[Y_AXIS];
 | 
			
		||||
      if (r && (p2 != p1 || q2 != q1)) {
 | 
			
		||||
        const float e = clockwise ^ (r < 0) ? -1 : 1,            // clockwise -1/1, counterclockwise 1/-1
 | 
			
		||||
                    dx = p2 - p1, dy = q2 - q1,                  // X and Y differences
 | 
			
		||||
                    d = HYPOT(dx, dy),                           // Linear distance between the points
 | 
			
		||||
                    dinv = 1/d,                                  // Inverse of d
 | 
			
		||||
                    h = SQRT(sq(r) - sq(d * 0.5f)),              // Distance to the arc pivot-point
 | 
			
		||||
                    mx = (p1 + p2) * 0.5f, my = (q1 + q2) * 0.5f,// Point between the two points
 | 
			
		||||
                    sx = -dy * dinv, sy = dx * dinv,             // Slope of the perpendicular bisector
 | 
			
		||||
                    cx = mx + e * h * sx, cy = my + e * h * sy;  // Pivot-point of the arc
 | 
			
		||||
        arc_offset[0] = cx - p1;
 | 
			
		||||
        arc_offset[1] = cy - q1;
 | 
			
		||||
      const float r = parser.value_linear_units();
 | 
			
		||||
      if (r) {
 | 
			
		||||
        const float p1 = current_position[X_AXIS], q1 = current_position[Y_AXIS],
 | 
			
		||||
                    p2 = destination[X_AXIS], q2 = destination[Y_AXIS];
 | 
			
		||||
        if (p2 != p1 || q2 != q1) {
 | 
			
		||||
          const float e = clockwise ^ (r < 0) ? -1 : 1,            // clockwise -1/1, counterclockwise 1/-1
 | 
			
		||||
                      dx = p2 - p1, dy = q2 - q1,                  // X and Y differences
 | 
			
		||||
                      d = HYPOT(dx, dy),                           // Linear distance between the points
 | 
			
		||||
                      dinv = 1/d,                                  // Inverse of d
 | 
			
		||||
                      h = SQRT(sq(r) - sq(d * 0.5f)),              // Distance to the arc pivot-point
 | 
			
		||||
                      mx = (p1 + p2) * 0.5f, my = (q1 + q2) * 0.5f,// Point between the two points
 | 
			
		||||
                      sx = -dy * dinv, sy = dx * dinv,             // Slope of the perpendicular bisector
 | 
			
		||||
                      cx = mx + e * h * sx, cy = my + e * h * sy;  // Pivot-point of the arc
 | 
			
		||||
          arc_offset[0] = cx - p1;
 | 
			
		||||
          arc_offset[1] = cy - q1;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user