Trig-CNC

Mathematics for the Machine Shop

Angles & Triangles
Where trig begins — and why it lives in every machining job

Almost every problem in a machine shop comes down to this: you know some measurements, and you need to find others. Trigonometry is just the toolkit for doing that with angles and right triangles.

🏭 In the Shop

You're drilling a hole 32 mm across from the edge of a part, and it needs to be at 38°. How far in the Y-axis do you move? How far in X? This is trig — used every day, every shift.

The Right Triangle Geometry

A right triangle has one 90° corner. Shop trig uses right triangles because machines move on orthogonal lines (X and Y axes). Adjust the slider below to see how the triangle's sides respond to changing the angle θ.

Hypotenuse (H) Opposite (O) Adjacent (A) θ
Interactive: Adjust the angle to see how Opposite and Adjacent lengths change while Hypotenuse remains fixed.

Naming the Sides

The side names change depending on which angle you reference. Always start by identifying your angle θ (theta):

  • Hypotenuse — Always the longest side, opposite the 90° corner. Fixed.
  • Opposite — The side directly across from your angle θ.
  • Adjacent — The side right next to your angle θ.
💡 Tooling mode

Always verify your scientific calculator is set to DEG (Degrees), not RAD (Radians). In machining, everything is degrees. If sin(30) returns negative, you're in radians.

SOH · CAH · TOA
The three formulas that solve 90% of shop floor trigonometry

SOH-CAH-TOA is an acronym for the three primary trigonometric ratios. Each establishes a relationship between an angle and two sides.

SOH
sin(θ) = O / H
Sine is Opposite divided by Hypotenuse
CAH
cos(θ) = A / H
Cosine is Adjacent divided by Hypotenuse
TOA
tan(θ) = O / A
Tangent is Opposite divided by Adjacent

By rearranging these, we generate the formulas used directly at the machine controller:

Find O:O = H × sin(θ)   |   O = A × tan(θ)
Find A:A = H × cos(θ)   |   A = O / tan(θ)
Find H:H = O / sin(θ)   |   H = A / cos(θ)
Find θ:θ = sin⁻¹(O/H)  |  cos⁻¹(A/H)  |  tan⁻¹(O/A)

Interactive Right Triangle Calculator

Knowledge Check

Question 1
You're milling a slot. The cut runs at 35° to the X-axis and is 90 mm long (hypotenuse). How far does the Y-axis (opposite) need to travel?
mm
Bolt Circle (PCD)
Program equally spaced hole patterns on CNC mills

A Pitch Circle Diameter (PCD) is a series of holes spaced evenly around a center point. To drill these manually or via basic CNC, you must convert polar coordinates (Radius and Angle) into Cartesian coordinates (X and Y limits).

Radius R:R = D / 2
Angle Step:Step = 360° / Holes
Hole (i) X:X = R × cos( StartAngle + i × Step )
Hole (i) Y:Y = R × sin( StartAngle + i × Step )

Bolt Circle Generator

#XY

Knowledge Check

Question 2
A flange has 8 equally spaced holes on a 160 mm diameter circle. The first hole starts at . What is the X coordinate of Hole #3 (which is at 90°)?
mm
Turning Tapers
Solving half-angles for lathe programming

A taper is mathematically an isosceles triangle wrapped around an axis. When setting a compound slide or programming a CNC lathe (G01 X Z), we care about the half angle (α/2) and the linear distance traveled.

D d Length (L)
Half Angle:α/2 = tan⁻¹( (D - d) / (2 × L) )
Full Angle:α = 2 × (α/2)

Taper Calculator

Sine Bar Setup

A sine bar creates a physical hypotenuse. You stack gauge blocks to raise one end (Opposite) to achieve a highly precise angle.

Stack H:H = L × sin(θ)
Compound Slide

Always set the manual engine lathe's compound to the half-angle of the desired taper to feed cleanly along one face.

Angular Moves

Converting a polar tool path (Distance at Angle) into Cartesian G-code (X, Y).

X Move:X = Dist × cos(θ)
Y Move:Y = Dist × sin(θ)
Coordinate Rotation

Rotating an entire geometry feature by angle φ dynamically.

X_new:X' = X·cos(φ) - Y·sin(φ)
Y_new:Y' = X·sin(φ) + Y·cos(φ)
🎉 Course Complete!

You have unlocked all modules and reviewed the core machine shop trigonometry formulas. Your math is now as dialed in as your machines.

About Trig-CNC
Mathematics for the Modern Machinist

Trig-CNC was developed to bridge the gap between abstract trigonometry and the practical, high-precision world of the machine shop. While computer-aided design (CAD) is everywhere, a machinist's true power comes from understanding the math that runs the machine.

Purpose

This application serves as both a reference and a training tool. Whether you are solving for a bolt circle PCD, calculating a Morse taper half-angle, or programming a coordinate rotation, Trig-CNC provides the formulas and interactive visualizers to ensure your first cut is your best cut.

Technical Details

Built with modern web technologies to be lightweight, portable, and responsive:

  • Frontend: Vanila HTML5, CSS3 (Custom Variables & Animations)
  • Physics: p5.js Particle System
  • Visuals: Interactive SVG Geometry
🛠️ Open Source

This project is designed to be a standalone, single-file tool. It can be run offline once loaded, making it ideal for shop-floor tablets and workstations.