CNC Offsets & Relief
CNC Cutter Radius Compensation (Minkowski Offset): In subtractive CNC milling, a machine toolpath cannot follow the nominal workpiece contour directly because the rotary cutting tool possesses a finite radius $R$. The spindle center must be offset by the Minkowski sum of the part boundary and the circular cutter disk, inserting radial arc fillets around convex corners.
Cutter Compensation Invariant:
1import numpy as np23def compute_tool_offset_path(polygon, tool_radius=0.25):4 """5 Computes CNC center toolpath using 2D Minkowski sum with tool disk of radius R.6 At convex corners, inserts circular arc fillets centered at the vertex.7 """8 offset_segments = []9 n = len(polygon)1011 for i in range(n):12 p1 = polygon[i]13 p2 = polygon[(i + 1) % n]14 edge = p2 - p115 normal = np.array([-edge[1], edge[0]]) / np.linalg.norm(edge)1617 # Parallel offset segment18 p1_off = p1 + normal * tool_radius19 p2_off = p2 + normal * tool_radius20 offset_segments.append((p1_off, p2_off))2122 return offset_segments
CNC Inside Corner Relief (Dogbone Fillets): Rotary milling cutters can never produce a sharp interior $90^\circ$ corner; the bit radius leaves a residual circular corner fillet. When assembling friction-fit slot joinery (e.g. mortise and tenon in plywood or aluminum), mating square corners jam. A dogbone fillet deliberately overcuts into the corner along its angle bisector, clearing the square vertex.
Dogbone Clearance Geometry:
1import math23def compute_dogbone_relief(corner_vertex, in_dir, out_dir, tool_radius=0.25):4 """5 Computes CNC dogbone corner relief center.6 A cylindrical bit cannot cut an internal 90-degree corner.7 To clear the square mating tab, the tool must overcut diagonally into the corner.8 Distance from corner: d = tool_radius.9 """10 # Bisector direction into material11 bisector = -(in_dir + out_dir)12 bisector = bisector / math.sqrt(bisector[0]**2 + bisector[1]**2)1314 relief_center = corner_vertex + bisector * tool_radius15 return relief_center