← Back to CNC Programming

Practical Mathematics for CNC Programming

You do not need advanced calculus. You need right triangles, circles, and consistent arithmetic — done carefully. This page covers the trigonometry and coordinate math you use every day at the machine.

What you will learn:

Concept

Every CNC coordinate comes from a dimension on a drawing. The math converts that dimension into X and Y values you type into the machine. The three tools you use constantly are: (1) the Pythagorean theorem for distances, (2) sin/cos for coordinates around a circle, and (3) careful sign handling for negative quadrants.

Why It Matters

A bolt circle with six holes at 60° spacing: if you use radians instead of degrees, or forget that Y is negative below the X axis, every hole is wrong. CNC math is unforgiving — there is no "close enough." Each independent absolute hole carries its own rounding error; it does not multiply by the number of holes automatically. Always double-check signs and quadrants.

The controller follows the programmed coordinates; it does not verify that your arithmetic matches the drawing. It will move to X = -50 when you meant +50. Verify coordinates against the drawing and a dry run or simulation before the first cut. Treat every coordinate as a number you would trust with a Ø50 finish-mill.

How It Works

Right Triangle Trigonometry

For a right triangle with angle θ, adjacent side a, opposite side b, hypotenuse c:

Mnemonic: SOH-CAH-TOA — Sine = Opposite/Hypotenuse, Cosine = Adjacent/Hypotenuse, Tangent = Opposite/Adjacent.

a (adjacent) b (opp.) c (hypotenuse) θ Right angle

Coordinates on a Circle

Given center (Xc, Yc), radius R, angle θ measured counterclockwise from the +X axis:

X = Xc + R × cos(θ)
Y = Yc + R × sin(θ)

Angles in the four quadrants: 0° = +X, 90° = +Y, 180° = −X, 270° = −Y. Negative angles or angles >360° are handled by the calculator's sin/cos functions automatically — but always check the sign makes sense.

0° (+X) 90° (+Y) 180° (−X) 270° (−Y) center

Example

Example 1: Bolt Circle (4 Holes)

Four holes on a pitch circle diameter (PCD) of 100 mm, center at (0,0), first hole at 0°:

HoleAngleX = R×cos(θ)Y = R×sin(θ)
10°50.0000.000
290°0.00050.000
3180°−50.0000.000
4270°0.000−50.000

PCD = 100 means diameter 100, so R = 50. Do not confuse PCD with radius.

Example 2: Bolt Circle (6 Holes)

Six holes at 60° spacing, R = 50, starting at 0°:

Example 3: Distance and Angle

Move from (0,0) to a point 20 mm away at 30°:

The straight-line distance between (10,10) and (50,30): ΔX = 40, ΔY = 20, distance = √(40² + 20²) = √2000 = 44.721 mm.

To find the angle between two points: θ = atan2(ΔY, ΔX). For the same points (ΔX=40, ΔY=20), atan2(20, 40) = 26.565°. The atan2 function (not atan) is important because it picks the correct quadrant automatically. Example: for Δ=(-40,-20), atan(20/40) = 26.565° but atan2(-20,-40) = -153.435° (or 206.565°) — the correct third-quadrant angle.

Example 4: Chamfer Calculation

On a mill, a C1 (1×45°) chamfer means the tool moves 1 mm in X and 1 mm in Z from the corner. The endpoint coordinates are shifted by 1 mm from the corner on both linear axes. On a lathe in diameter mode, the same C1 chamfer means 1 mm radial depth, which is a 2 mm change in X (diameter) for every 1 mm of Z. Always check whether the drawing dimension refers to the linear axis (mill) or the diameter (lathe).

For a non-45° chamfer, be explicit about which length is given. If the chamfer length along the angled face is 2 mm at 30° from horizontal: vertical depth = 2×sin(30°) = 1.000 mm, horizontal projection = 2×cos(30°) = 1.732 mm. If instead the horizontal projection is 2 mm at 30°: vertical depth = 2×tan(30°) = 1.155 mm. These are different problems; the drawing must say which.

Arc, Chord, and Sagitta

When a drawing calls out an arc, you need three numbers: the radius R, the start point, and the end point. The chord length (straight line between start and end) is:

chord = 2 × R × sin(θ/2)

where θ is the included angle. The sagitta (height of the arc above the chord) is:

sagitta = R − R × cos(θ/2)

Example: R = 25 mm, included angle 90°. Chord = 2×25×sin45 = 35.355 mm. Sagitta = 25 − 25×cos45 = 7.322 mm. Arc length L = R×θ(radians) = 25 × (90×π/180) = 39.270 mm. These are the numbers you need to program the arc and to verify it against a CMM measurement.

It is worth pausing on what each of these three numbers means, because they are easy to confuse. The chord is the straight-line distance between the arc endpoints — it is what a CMM measures when it touches the two ends. The arc length is the distance along the curved tool path — it is what the tool actually cuts, and it is longer than the chord. The sagitta (or rise) is the distance from the midpoint of the chord to the highest point of the arc — it is how much the part bulges out, and it is what you check if the drawing calls out the arc height. For a 90° arc on R25, the chord is 35.355 mm, the arc is 39.270 mm, and the sagitta is 7.322 mm. None of these three numbers can be used in place of another. Suppose the drawing separately calls out R25 ±0.02 at exactly 90°. The ideal radius band is 24.98–25.02 mm. From c = R√2 the chord band is about 35.327–35.384 mm; from h = (1−cos45°)R the sagitta band is about 7.316–7.328 mm. These allowances are not all ±0.02 — they are derived from the radius band under a fixed-angle, ideal-circle model. Real acceptance follows whatever the drawing calls out (radius, profile, or chord) and the chosen measurement plan; passing a chord check does not by itself prove the whole arc profile is in tolerance. The arc length is the distance along this analyzed tool path; if R25 is a part contour, the tool-center path may differ once cutter compensation is applied. Final coordinate rounding is checked in the program, not by blaming setup offsets for pure rounding error.

Taper and Included Angle

On a lathe, a taper is specified either as an included angle (e.g., 30° included) or as a taper per foot/meter. If the large diameter is D, the small diameter is d, and the length is L, the included angle α satisfies:

tan(α/2) = (D − d) / (2 × L)

Example: D = 40, d = 30, L = 50. tan(α/2) = 10/100 = 0.1, so α/2 = 5.71°, included angle = 11.42°. The half-angle is what the tool feeds along — the tool moves radially 5 mm over 50 mm of Z. This is also the angle G01 interpolation follows when programming a taper straight between two diameters.

Cutting Time and Feed Arithmetic

Cutting time in minutes = length of cut ÷ feed rate (when F is length per minute, G94). For a straight cut of 60 mm at F300 mm/min: time = 60/300 = 0.2 minutes = 12 seconds. This ignores acceleration/deceleration. For turning at F0.2 mm/rev and S800 RPM: feed rate = 0.2 × 800 = 160 mm/min, so 60 mm takes 60/160 = 0.375 min = 22.5 seconds. In constant surface speed (G96) turning, RPM changes with diameter, so the per-minute feed is not constant.

These calculations let you estimate cycle time before running the machine, and spot when a feed override is set wrong. If a cut that should take 12 seconds is taking a minute, the feed override is likely at 20% or the program feed is wrong.

Rounding and Precision

Controllers typically accept coordinates to 0.001 mm (or 0.0001 inch). Keep full calculator precision through intermediate steps and round only the final coordinate. For example, 50×cos60.000° = exactly 25.000, but 50×sin60.000° = 43.301270... — write 43.301, not 43.3. Rounding 43.30127 to 43.3 introduces a 0.00127 mm error at that coordinate. Each G90 hole position is independent, so the error does not add up across holes in a bolt circle; in an incremental chain it would accumulate. Compare the final rounded value against the part tolerance before releasing the program.

Coordinate Conversion: Millimeters to Inches

Shops that mix metric and imperial drawings need quick conversion. 1 inch = 25.4 mm exactly. A 3-inch hole is 76.2 mm. A 50 mm coordinate is 1.9685 inches. When a program uses G21 (mm), coordinates and distances are in mm; when it uses G20 (inch), they are in inches. Feed F depends on both the unit mode (G20/G21) and the feed mode (G94 per minute vs G95 per revolution). The controller does not convert for you — the numbers mean whatever the active G-codes declare. This is why a unit mismatch scales every coordinate by 25.4.

Interpolation: How the Controller Moves

When you program G01 X50 Y30, the controller computes the straight line from the current point to (50,30) and moves the tool along it at the programmed feed. The feed rate applies to the tool center along that line — not to X or Y individually. If the move is at 30°, the X component of motion is F×cos30 and the Y component is F×sin30, but the tool center still moves at F along the diagonal. You do not need to split F yourself; the controller does it.

Arc Endpoint and Radius: I/J vs R

When programming G02/G03, you can define the arc either by the center offset (I, J, K) or by radius R. On the Haas mill in G17 (XY plane) used here, I and J are the incremental distance from the arc start point to the arc center; R is the radius, with a negative R selecting the long way around for arcs greater than 180°. These rules are stated for this controller and plane; verify on your specific control before relying on them.

Worked Example: Hole Pattern on a Plate

A rectangular plate 100×60 mm has four mounting holes, each 10 mm in from the edges. Work zero at the bottom-left corner. Hole coordinates: (10,10), (90,10), (90,50), (10,50). These come straight from the drawing dimensions — no trigonometry needed because the holes are on a rectangular grid. If the holes were instead on a 60 mm PCD centered at (50,30), you would use the bolt-circle formula: X = 50 + 30×cos(θ), Y = 30 + 30×sin(θ).

Center Distance and Pitch

When a drawing calls for holes on a linear pitch (for example, 5 holes at 20 mm spacing), the coordinates are simple arithmetic: hole 1 at X = start, hole 2 at X = start + 20, hole 3 at start + 40, and so on. This is the G91 incremental pattern — each hole is 20 mm from the previous one. If the holes are dimensioned from the left edge, use G90 absolute coordinates directly from the drawing. Both methods produce the same physical positions; choose the one that matches how the drawing is dimensioned.

Feeds and Speeds: The Most Common Calculation

The daily calculation at the machine: given cutting speed Vc (m/min) and tool diameter D (mm), spindle RPM is N = 1000 × Vc / (π × D). For a Ø10 end mill at 100 m/min: N = 1000 × 100 / (3.1416 × 10) = 3183 RPM. Feed rate is F = N × fz × z, where fz is feed per tooth (mm/tooth) and z is the number of flutes. For a 4-flute end mill at fz = 0.05 mm/tooth: F = 3183 × 0.05 × 4 = 637 mm/min. These are classroom assumptions; real values come from tooling catalogs.

Lathe-Specific Math

In the diameter-mode lathe examples on this page, X represents diameter. A cut from Ø50 to Ø46 over 2 mm of Z: the radial depth of cut is (50 − 46)/2 = 2 mm, not 4 mm. The taper angle over that cut: tan(θ) = 2/2 = 1, so θ = 45° on one side. When programming a chamfer on a lathe, remember that the X coordinate is the diameter — a 1×45° chamfer means X changes by 2 mm (from Ø40 to Ø38) for every 1 mm of Z.

Always double-check whether a drawing dimension calls out diameter or radius before converting to coordinates. On a lathe, the answer is almost always diameter; on a mill, circle dimensions are usually diameter but bolt-circle references can be either.

Common Mistakes

Practice

1. Center at (10,20), radius 20, point at 90°. What are the coordinates?

Show answer

X = 10 + 20×cos90 = 10. Y = 20 + 20×sin90 = 40. Answer: (10, 40).

2. Two points at (5,8) and (−5,18). What is ΔX and ΔY?

Show answer

ΔX = −5 − 5 = −10. ΔY = 18 − 8 = +10. The displacement is (−10, +10).

3. Why not round intermediate results to 0.1 mm?

Show answer

Rounding accumulates error. Keep full calculator precision and round only the final output.

4. Six-hole bolt circle, PCD = 80, center at (0,0). Hole 3 is at 120°. What are its coordinates?

Show answer

R = 40. X = 40×cos120 = −20.000. Y = 40×sin120 = 34.641. Answer: (−20, 34.641).

5. R = 25 mm, included angle 90°. What is the chord length?

Show answer

Chord = 2×25×sin(45°) = 50×0.7071 = 35.355 mm.

Sources