CNC controllers cut arcs with circular interpolation, and the trickiest part of hand-coding one is computing the I and J center offsets. This tool takes a start point, an end point, and a radius, computes the exact I and J values for both possible arc solutions, and outputs a ready-to-paste G02 or G03 line.
How it works — the geometry
The arc center must be equidistant from both endpoints, so it lies on the perpendicular bisector of the chord connecting them. Using the chord length and the radius, the distance from the chord midpoint to the center is found by Pythagoras, giving two centers — one on each side of the chord:
chord = distance(start, end)
half = chord / 2
a = sqrt(radius² − half²)
center = midpoint ± a × (unit perpendicular to chord)
I = center X − start X
J = center Y − start Y
For each center the tool measures the swept angle in both directions to decide whether the minor arc is clockwise (G02) or counter-clockwise (G03), and marks the solution with the smaller sweep angle as the shorter arc.
Worked example
For a start point at (0, 0), end point at (10, 10), and radius 10:
- Chord length = sqrt(10² + 10²) ≈ 14.14
- Half-chord = 7.07; distance from midpoint to center = sqrt(10² − 7.07²) ≈ 7.07
- Two centers: (10, 0) and (0, 10)
This gives two 90° arcs going in opposite directions:
| Solution | Center | I | J | Code | Sweep |
|---|---|---|---|---|---|
| Minor arc 1 | (10, 0) | +10.0 | 0.0 | G02 | 90° |
| Minor arc 2 | (0, 10) | 0.0 | +10.0 | G03 | 90° |
Both are 90° sweeps here (equal for a symmetric case). Choose the one whose bulge direction matches your intended toolpath, then copy the G-code line:
G02 X10.0 Y10.0 I10.0 J0.0 F200
Controller compatibility and edge cases
Incremental vs absolute I/J. The output uses incremental I and J (offset from the arc start to the center), which is the default on Fanuc, Haas, Mazak, LinuxCNC, and most other common controllers. If your machine uses absolute arc center mode (enabled by G90.1 on some Fanuc systems), use the printed center X/Y coordinates as I/J instead.
Radius too small error. An arc’s radius cannot be smaller than half the chord between the endpoints — the geometry has no solution. If you see this warning, either increase the radius or move the endpoints closer together.
Full circles. When start and end are the same point, I and J can define a full-circle arc. Most controllers require a full-circle move to be programmed as a single 360° arc with no endpoint specified, which this tool does not generate — use your CAM software for full circles.
G18 and G19 planes. This calculator targets the G17 XY plane, the default for most milling operations. For G18 (XZ plane) or G19 (YZ plane), the same geometry applies but the offset letters swap: I/K for G18 and J/K for G19. Verify your active plane modal before using the output.