Algorithmadvanced
Principal axis method
Also called Rao-Ismail-Bedi method.
Five-axis method of Rao, Bedi and coauthors that tilts a toroidal or flat end mill in the minimum curvature plane so its effective radius matches the maximum curvature.
- Time
- O(m) worst
- Space
- O(1) extra
- Where
- m = number of cutter contact points
- Model
- Real RAM
- Properties
- deterministiciterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- N. Rao, Sanjeev Bedi, Ralph O. Buchal, Fathy Ismail, 1996
The principal axis method (PAM) chooses the tool orientation of a flat or toroidal end mill at each cutter contact point in five-axis milling. It tilts the tool axis away from the surface normal in the plane of minimum curvature, by the smallest angle at which the tilted tool, seen along the feed direction, curves as much as the surface does in the plane of maximum curvature. The tilted flat bottom then fits the surface across the feed much more closely than a ball end mill of the same size, so each pass cuts a wider strip and fewer passes are needed for a given scallop height. This is a manufacturing method of mechanical CAD: it decides how a cutter is held against a part. It is not about the placement and routing of a circuit. The tilt comes from one formula in the principal curvatures, and on a concave cylinder the formula is exact: it gives the smallest tilt that does not gouge, and the closest fit.
In plain words
A flat-bottomed cutter held straight up against a curved hollow touches it with its sharp rim and leaves deep ridges. A round-ended cutter fits better, but it cuts only a narrow band at a time.
Tip the flat cutter forward a little, in the direction along which the surface is nearly straight. Seen from the front, its round bottom edge now looks like a flat oval. For a small tip the oval is very flat, and its bottom is a wide, gentle curve.
The method picks the tip at which the bottom of the oval curves exactly as much as the hollow does across. Tip less and the oval digs in at the sides. Tip more and it stands away from the surface and leaves more material. At the right tip the cutter hugs the hollow over a wide band.
The problem
At a cutter contact point the surface has the unit normal , pointing to the tool, the principal directions and , and the normal curvatures , with a positive curvature where the surface bends toward the tool (a concave part). The tool is a toroidal end mill: its center circle, the circle of the centers of the corner arcs, has radius and lies at height above the tip, where is the corner radius. A flat end mill is the case . The task is to choose the tool axis and the tip position so that the tool touches with normal , does not cut into the surface near , and leaves as little material as possible across the feed. This is one case of the five-axis tool orientation problem, solved locally at each point.
The key quantity is the effective radius of the tool. Tilt the axis by the angle from toward , and look along . The center circle projects to an ellipse with semi axes and , whose radius of curvature at its lowest point is . The corner adds , so the tool cuts a profile with the radius
in the plane of maximum curvature. A profile with a smaller radius than the surface, , leaves a small gap. A profile with a larger radius gouges the sides.
The algorithm
PRINCIPAL-AXIS-METHOD(p, n, e_min, κ_max, R, r, λ_min)- 1
if κ_max ≤ 0 then ▷ convex or flat across the feed - 2
λ ← λ_min - 3
else ρ ← 1/κ_max ▷ radius of the surface across the feed - 4
if R > ρ − r then fail: no tilt avoids a gouge - 5
λ ← max(arcsin(R/(ρ − r)), λ_min) ▷ R/sin λ + r = ρ - 6
a ← cos λ · n + sin λ · e_min ▷ tilt in the plane of minimum curvature - 7
e ← cos λ · e_min − sin λ · n ▷ in the tip plane, toward the contact - 8
c ← p + r n − r a − R e ▷ tip center; the corner touches p - 9
return (λ, a, c)
Line L5 solves . Line L8 puts the lowest corner center at , so the corner arc touches with normal . The tool feeds along in the basic method, so the swept cross-section is the effective profile in the plane of and . The lower bound keeps the center of the flat bottom, where the cutting speed is zero, off the surface, and it is the tilt used on convex parts, where any tilt is free of local gouges.
Example
A toroidal end mill of diameter 20 mm has and . It cuts the inside of a cylinder of radius , feeding along the axis. At the bottom, , and .
| line | value |
|---|---|
| L3 | , and |
| L5 | , |
| L6 | |
| L7 | |
| L8 |
The effective radius is , and with the corner the cut profile has radius 50, equal to the surface. The table below gives the width of the strip across the feed in which the vertical gap between the tool and the surface is at most , computed by sampling the swept profile.
| tool and tilt | strip width for |
|---|---|
| toroidal, (PAM) | 8.06 |
| toroidal, | 3.98 |
| toroidal, | 2.74 |
| toroidal, | 2.02 |
| ball end mill of radius 10 | 1.00 |
A tilt below gouges the sides. For the ball, the effective radius against the concave surface is , and the strip is wide. The PAM strip is eight times wider. The reason is the order of contact: at the PAM tilt the clearance grows like the fourth power of the distance from the contact, and at any other tilt it grows like the square.
Correctness
Theorem. Take a concave circular trough of radius , feed along its axis with a fixed tool axis, and a toroidal end mill with . The tool placed by lines L6 to L8 at tilt makes no gouge if and only if . At every point of the cutting edge the clearance to the surface grows with , so the tilt of line L5 is the smallest tilt without a gouge and the closest fit at every point of the edge. At that tilt the cut profile has the radius at the contact, and the clearance is of fourth order in the distance from it.
The proof is in the proof file. The distance of a tool point from the axis of the trough decides a gouge, and by the triangle inequality the worst point is a corner center plus . For the corner center at angle , with and ,
which is at most 0 for all exactly when . The derivative in is negative, which gives the monotone clearance. At equality the first term vanishes, and the clearance is to leading order.
The model is stated in full: a cylinder, a feed along the zero-curvature direction, and a tool axis that does not turn during the pass. On a general surface the formula only matches the second-order shape of the surface at , and nothing is proved about points away from . The tests check the theorem by a grid search over tilts that uses a direct 3D test of the placed tool in the trough and no curvature formula, and by exact rational arithmetic at the tilt , where the tool touches the trough at one point of its edge and nowhere goes in.
Proof: On a concave cylinder, the PAM tilt is the smallest tilt without a gouge, it gives the least clearance at every point of the cutting edge, and its effective profile has the curvature of the surfacefull
Model. The part is a concave circular trough of radius . In coordinates its axis is the line and its bottom line is . A point of the tool is in the material (a gouge) when . The contact point is , the normal is , the minimum curvature direction is (curvature 0), and the maximum curvature is in the direction . The tool feeds along with a fixed axis.
The tool is a toroidal end mill. Its center circle has radius and lies at height above the tip plane, and the corner radius is . With it is a flat end mill. The solid tool is the set of points at axial height above the tip with a distance from the tool axis of at most for , and at most for . Only the part of the tool at or below the height of the trough axis counts, as a trough is open above. Write and assume , so the corner of the tool is below the height of the trough axis.
For a tilt , write , , and place the tool by lines L6 to L8: axis , direction , tip center .
Claim. Let , which exists when .
(a) The tool at tilt makes no gouge if and only if .
(b) At each point of the center circle, given by its angle from , the clearance grows with . So is the smallest tilt without a gouge, and of all tilts without a gouge it puts every point of the cutting edge nearest to the surface. With a lower bound , the best tilt is , which line L5 returns.
(c) At the cross-section of the swept tool has the radius of curvature at the contact point, the same as the trough. The tool touches the trough along the line only, and the clearance near it is of fourth order in the distance from the contact.
If , every tilt makes a gouge, and line L4 reports it.
Step 1: the gouge test reduces to the center circle. The distance from does not depend on , so the feed motion along does not change it. The function is convex and 1-Lipschitz. For and , , with equality when is times the unit vector from to at right angles to . The ball is in the tool, since the solid torus is the corner of the tool together with points inside it. The rest of the tool is the convex hull of the bottom circle (radius , height 0) and of , which are in , and the shank above height . A shank point is with on the disk of radius at height and . As points up, decreases in while the point stays below the axis height. By convexity, the maximum of the distance over the convex hull and over that disk is on their boundary circles, which are in . So
and the tool makes no gouge if and only if for every .
Step 2: the center circle in coordinates. The vector completes the frame of the tool. The center circle is , and . So
Seen along , the center circle is an ellipse with semi axes and , with its lowest point at height above . Put , so . Then
Proof of (a). Note and . If , both terms in the bracket of are at most 0, so for every and there is no gouge by Step 1. If , then for , or for every when , the bracket is positive and , which is a gouge. The condition is , that is . If this needs , so no tilt works.
Proof of (b). Fix , so is fixed. As grows in , grows, and
since . So does not grow, and the clearance does not shrink, as grows. By (a), the tilts without a gouge are exactly , so the smallest of them, , gives the least clearance at every . With the bound , the feasible set is , and the same argument picks its smallest element.
Proof of (c). The swept cross-section is the projection of the tool along . By Step 1, near the contact its lower boundary is the lower arc of the ellipse grown by a disk of radius , that is, the offset of the ellipse at distance . An ellipse with semi axes has the radius of curvature at the ends of its short axis, and the offset at distance outward adds to the radius of curvature. So the cut profile has radius at the contact. At this is . At , becomes , which is 0 only at when , so the tool touches along only. As , the clearance is , which is of fourth order. For the first term of is , and the clearance is of second order in .
Remarks. (1) The claims hold for the trough, where the feed direction has zero curvature and the axis of the tool is fixed along the feed. On a general surface, PAM uses the same formula with at each contact point. This matches the second-order shape of the surface in the plane of maximum curvature, but it does not prove the absence of a gouge away from the contact point, and a global gouge check is still needed. (2) The tests check (a) and (b) by a grid search over tilts with a direct 3D test of the tool in the trough, and they check (a) and the single touch point of (c) with exact rational arithmetic at the tilt .
Complexity
Each contact point costs arithmetic after the principal curvatures and directions are known, which for a parametric surface is also from the first and second derivatives. A path of contact points takes time and extra space. The real cost of a PAM tool path is elsewhere: in the global gouge and collision checks that the local formula does not cover, and in choosing the paths and the step between them.
Properties
- Local. The tilt depends only on the curvature at the contact point.
- Exact on cylinders. On a concave cylinder with the feed along the axis, the tilt is the smallest that does not gouge and gives the closest fit.
- Wide strips. At the matched tilt the clearance is of fourth order across the feed, so the strip for a given scallop height is much wider than for a ball end mill.
- Needs concavity across the feed. On convex or flat parts there is nothing to match, and the method falls back to the minimum tilt.
Variants and improvements
- Inclined tool method. The older inclined tool method tilts a flat or toroidal end mill by a fixed angle in the feed direction. PAM replaces the fixed angle by the curvature-matched one and ties the tilt to the principal directions.
- Feed direction. Rao, Ismail and Bedi (1997) compared tool paths with different feed directions while the tilt follows the principal axes. Feeding along the minimum curvature direction makes the swept section equal to the effective profile of the theorem.
- Multi-point machining. Later methods tilt and rotate the tool so that it touches the surface at two points instead of one, which gives a still wider strip on some surfaces.
- Rolling ball and arc-intersect methods. These methods of the same school choose the axis from a circle that fits the surface, and they target global gouges as well as local ones.
- Iso-scallop paths. The effective radius gives the scallop height between passes, so PAM can feed an iso-scallop path planner.
When to use it
Use PAM for five-axis finishing of large, gently curved parts that are concave across the feed, such as dies, molds and turbine passages, with a flat or toroidal end mill. Use a ball end mill, or a gouge-checked method such as a multi-point method, where the curvature changes fast or where the part is small compared with the tool.
Pitfalls
- Matching only at one point. The formula matches the curvature at . If the curvature changes within the width of the tool, the tool can gouge at the edge of the strip. Check the result with gouge detection.
- Global gouges and collisions. The tilted tool and its holder can hit other parts of the surface. PAM does not see this, so an accessibility or collision-free orientation step is still needed.
- Too wide a tool. If , no tilt avoids a gouge. Use a smaller tool or a ball end mill there.
- Umbilic points. Where , the principal directions are not defined, and the tilt direction can jump. Smooth the directions or fix the feed direction near such points.
- Sign of curvature. The formula needs the curvature with the sign that is positive for a concave part, as seen from the tool. With the other sign the method tilts on a convex part and wastes the fit.
- Feed curvature. The theorem assumes zero curvature along the feed. A curved feed direction also bends the swept volume, and the effective profile changes.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/principal-axis-method/. The authors are listed in prov/WFBXPX.jsonl.
"""Principal axis method (PAM) for five-axis milling with a toroidal end mill.
The tool is a toroidal end mill: a flat bottom disk of radius R and a corner
of radius r. The centers of the corner circles form the center circle C, of
radius R, in the plane at height r above the tool tip. With r = 0 the tool
is a flat end mill.
At a cutter contact point p the surface has the unit normal n (pointing out
of the material, toward the tool), the unit direction e_min of minimum
normal curvature and the maximum normal curvature kappa_max. A curvature is
positive where the surface bends toward the tool (a concave part, such as
the inside of a trough).
PAM tilts the tool axis away from n by the angle lam in the plane of n and
e_min. Seen along e_min, the tilted center circle is an ellipse with semi
axes R and R sin(lam). Its radius of curvature at the lowest point is
R / sin(lam), so the tool cuts a profile of radius R / sin(lam) + r in the
plane of maximum curvature. PAM picks the smallest tilt for which this
radius is not less than 1 / kappa_max:
sin(lam) = R / (1/kappa_max - r).
Numbers may be float or Fraction. With Fractions, tool_pose_sc takes the sine
and cosine of the tilt and is exact.
"""
import math
def _add(u, v):
return tuple(a + b for a, b in zip(u, v))
def _scale(k, u):
return tuple(k * a for a in u)
def _cross(u, v):
return (u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0])
def pam_tilt(R, r, kappa_max, lam_min=0.0):
"""The PAM tilt angle in radians, from the tool and the maximum curvature."""
if R <= 0 or r < 0:
raise ValueError("the tool needs R > 0 and r >= 0")
if kappa_max <= 0: # @line L1
return lam_min # @line L2
rho = 1 / kappa_max # @line L3
if R > rho - r: # @line L4
raise ValueError("no tilt avoids a gouge: the tool is too wide for the curvature")
return max(math.asin(R / (rho - r)), lam_min) # @line L5
def tool_pose_sc(p, n, e_min, s, c, R, r):
"""Place the tool for a tilt with sine s and cosine c.
Returns (axis, tip, e): the unit tool axis, the center of the tool tip
(the bottom disk) and the unit direction e in the bottom plane from the
axis to the lowest point of the center circle.
"""
axis = _add(_scale(c, n), _scale(s, e_min)) # @line L6
e = _add(_scale(c, e_min), _scale(-s, n)) # @line L7
tip = _add(_add(p, _scale(r, n)), _add(_scale(-r, axis), _scale(-R, e))) # @line L8
return axis, tip, e
def tool_pose(p, n, e_min, lam, R, r):
"""Place the tool for the tilt angle lam (radians)."""
return tool_pose_sc(p, n, e_min, math.sin(lam), math.cos(lam), R, r)
def principal_axis_method(p, n, e_min, kappa_max, R, r, lam_min=0.0):
"""Run PAM at one contact point. Returns (lam, axis, tip)."""
lam = pam_tilt(R, r, kappa_max, lam_min)
axis, tip, _ = tool_pose(p, n, e_min, lam, R, r)
return lam, axis, tip # @line L9
def center_circle_point(axis, tip, e, R, r, cos_t, sin_t):
"""The point of the center circle at the angle t from e, given cos t and sin t."""
w = _cross(axis, e)
return _add(_add(tip, _scale(r, axis)), _add(_scale(R * cos_t, e), _scale(R * sin_t, w)))
test_principal_axis_method.py 169 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/principal-axis-method/. The authors are listed in prov/WFBXPX.jsonl.
import math
import random
from fractions import Fraction as F
import pytest
from principal_axis_method import (
center_circle_point,
pam_tilt,
principal_axis_method,
tool_pose,
tool_pose_sc,
)
# The test part is a concave trough: the inside of a cylinder of radius rho
# whose axis is the line y = 0, z = rho. The contact point is the bottom of
# the trough, p = 0, with the normal n = +z. The minimum curvature direction
# is the axis direction +x (curvature 0) and the maximum curvature is 1/rho,
# across the trough. The tool feeds along +x.
P = (0, 0, 0)
N = (0, 0, 1)
E_MIN = (1, 0, 0)
def axis_distance(q, rho):
return math.hypot(q[1], q[2] - rho)
def gouge_and_clearance(lam, R, r, rho, samples=360):
"""Direct 3D check of the tool placed with tilt lam in the trough.
The solid tool is the center circle C grown by a ball of radius r, plus
parts that are nearer to the trough axis. A tool point is in the material
when its distance from the trough axis exceeds rho. So the gouge depth is
max over C of dist(q, axis) + r - rho, and the mean clearance of the
cutting edge is the mean over C of rho - r - dist(q, axis). No curvature
formula is used here.
"""
axis, tip, e = tool_pose(P, N, E_MIN, lam, R, r)
worst = -math.inf
total = 0.0
for i in range(samples):
t = 2 * math.pi * i / samples
q = center_circle_point(axis, tip, e, R, r, math.cos(t), math.sin(t))
d = axis_distance(q, rho)
worst = max(worst, d + r - rho)
total += rho - r - d
return worst, total / samples
def grid_search(R, r, rho, step_deg=0.1, max_deg=30.0, tol=1e-9):
"""The tilt on a grid that keeps the tool closest to the trough without a gouge."""
best = None
k = 1
while k * step_deg <= max_deg:
lam = math.radians(k * step_deg)
gouge, clearance = gouge_and_clearance(lam, R, r, rho)
if gouge <= tol and (best is None or clearance < best[1]):
best = (lam, clearance)
k += 1
return best[0]
def test_tilt_example():
lam = pam_tilt(8.0, 2.0, 1 / 50.0)
assert math.isclose(math.sin(lam), 1 / 6)
assert math.isclose(math.degrees(lam), 9.594068226860461)
assert math.isclose(8.0 / math.sin(lam) + 2.0, 50.0)
@pytest.mark.parametrize("seed", [None, 1, 2, 3])
def test_matches_grid_search_on_cylinder(seed):
if seed is None:
R, r, rho = 8.0, 2.0, 50.0
else:
rng = random.Random(seed)
R = rng.uniform(2.0, 10.0)
r = rng.choice([0.0, rng.uniform(0.5, 3.0)])
rho = (R + r) * rng.uniform(2.5, 8.0)
lam = pam_tilt(R, r, 1 / rho)
found = grid_search(R, r, rho)
assert abs(found - lam) < math.radians(0.1) + 1e-12
gouge, _ = gouge_and_clearance(lam, R, r, rho)
assert gouge <= 1e-9
def test_smaller_tilt_gouges_larger_tilt_leaves_more():
R, r, rho = 8.0, 2.0, 50.0
lam = pam_tilt(R, r, 1 / rho)
g_small, _ = gouge_and_clearance(lam - math.radians(0.5), R, r, rho)
g_star, c_star = gouge_and_clearance(lam, R, r, rho)
g_big, c_big = gouge_and_clearance(lam + math.radians(0.5), R, r, rho)
assert g_small > 1e-6
assert g_star <= 1e-9 and g_big <= 1e-9
assert c_big > c_star
def exact_distance2(s, c, R, r, rho, t):
"""Squared distance from the trough axis of a center circle point, exactly.
The angle on the circle is given by its rational parameter t:
cos = (1 - t^2) / (1 + t^2), sin = 2t / (1 + t^2).
"""
axis, tip, e = tool_pose_sc(P, N, E_MIN, s, c, R, r)
cos_t = (1 - t * t) / (1 + t * t)
sin_t = 2 * t / (1 + t * t)
q = center_circle_point(axis, tip, e, R, r, cos_t, sin_t)
return q[1] * q[1] + (q[2] - rho) ** 2
def test_exact_touch_at_the_pythagorean_tilt():
# R = 7, r = 1, rho = 26: sin(lam) = 7 / 25 and cos(lam) = 24 / 25 are rational.
R, r, rho = F(7), F(1), F(26)
s, c = F(7, 25), F(24, 25)
assert s == R / (rho - r)
limit = (rho - r) ** 2
ts = [F(k, 20) for k in range(-400, 401)]
for t in ts:
d2 = exact_distance2(s, c, R, r, rho, t)
assert d2 <= limit
assert (d2 == limit) == (t == 0)
def test_exact_gouge_below_the_tilt():
# sin = 9 / 41 < 7 / 25: some point of the tool is in the material.
R, r, rho = F(7), F(1), F(26)
limit = (rho - r) ** 2
ts = [F(k, 20) for k in range(-40, 41)]
for s, c in [(F(9, 41), F(40, 41)), (F(11, 61), F(60, 61))]:
assert any(exact_distance2(s, c, R, r, rho, t) > limit for t in ts)
# and a larger tilt, sin = 8 / 17, has no contact except the bottom
s, c = F(8, 17), F(15, 17)
for t in ts:
d2 = exact_distance2(s, c, R, r, rho, t)
assert d2 <= limit and (d2 == limit) == (t == 0)
def test_pose_touches_p_with_normal_n():
rng = random.Random(7)
for _ in range(50):
R = rng.uniform(1, 10)
r = rng.uniform(0, 3)
lam = rng.uniform(0, 1.2)
axis, tip, e = tool_pose(P, N, E_MIN, lam, R, r)
assert math.isclose(sum(a * a for a in axis), 1.0)
assert abs(sum(a * b for a, b in zip(axis, e))) < 1e-12
q = center_circle_point(axis, tip, e, R, r, 1.0, 0.0)
# the lowest corner center is r above p along n
assert all(abs(a - b) < 1e-12 for a, b in zip(q, (0.0, 0.0, r)))
def test_convex_and_flat_use_the_minimum_tilt():
assert pam_tilt(8.0, 2.0, -1 / 40.0, lam_min=0.05) == 0.05
assert pam_tilt(8.0, 2.0, 0.0, lam_min=0.05) == 0.05
# a hard minimum tilt wins over a small matched tilt
assert pam_tilt(8.0, 2.0, 1 / 1000.0, lam_min=0.1) == 0.1
def test_whole_method_and_errors():
lam, axis, tip = principal_axis_method(P, N, E_MIN, 1 / 50.0, 8.0, 2.0)
assert math.isclose(math.sin(lam), 1 / 6)
assert axis[1] == 0 and axis[0] > 0 and axis[2] > 0
with pytest.raises(ValueError):
pam_tilt(8.0, 2.0, 1 / 9.0) # R = 8 > rho - r = 7
with pytest.raises(ValueError):
pam_tilt(0.0, 2.0, 1 / 50.0)
History
The inclined tool method of the 1980s tilted a flat end mill by a fixed angle so that its rim fitted the surface better than a ball. Rao, Bedi and Buchal (1996) described an implementation of the principal axis method, which ties the tilt to the principal curvature directions and matches the effective radius to the maximum curvature, and Rao, Ismail and Bedi (1997) used it to study how the feed direction changes five-axis tool paths, with machining tests on two surfaces. The group at the University of Waterloo later developed the multi-point, rolling ball and arc-intersect methods from the same idea of fitting the tool to the local shape of the part.
References
- N. Rao, F. Ismail and S. Bedi, Tool path planning for five-axis machining using the principal axis method, International Journal of Machine Tools and Manufacture 37(7), 1025-1040, 1997, the principal axis method and the comparison of tool paths with different feed directions
- N. Rao, S. Bedi and R. Buchal, Implementation of the principal-axis method for machining of complex surfaces, The International Journal of Advanced Manufacturing Technology 11(4), 249-257, 1996, the tilt of the tool in the plane of minimum curvature and the effective radius of the tool in the plane of maximum curvature
- Byoung K. Choi and Robert B. Jerard, Sculptured Surface Machining, Theory and Applications, Kluwer Academic Publishers, 1998, the material on tool positioning for five-axis machining with flat and toroidal end mills
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag WFBXPX Edit this page History Report an error Markdown