Resources Numerical accuracy
Calculations
Every calculation under our calculation policies: what it works out, its formula and the precision it runs at. Open one to see its code as it is in the released app.
Calculations
-
Engagement check
Re-simulates the passes on a finer grid and reports the largest engagement angle, the equivalent cutting width, uncut area and the smallest wall clearance.
angle = 360 × (rim points in material) ÷ 360; width = R (1 − cos angle); gouge = min(dist to walls − R − leave)
Adaptive clearing passes cam-adaptive.js64-bit- PartCraft
-
Height grid of the part
Samples the part's top surface on a grid for the first search of the tool-tip height.
H[i, j] = height at cell center; cell = max(0.02, R ÷ 8)
3D finishing toolpaths cam-finish.js32-bit in part- PartCraft
-
Tool-tip height
The lowest height at which the tool at (x, y) touches the part without cutting into it.
z = max(H − h(ρ)) over grid samples within R; refine at ρ* = A + r_c s ÷ √(1 + s²) uphill; then max over triangle edges by ternary search; result = max(z + leave, floor)
3D finishing toolpaths cam-finish.js32-bit in part- PartCraft
-
Slope filter
Whether the surface under a point is within the slope range chosen for the operation.
s = √(g_x² + g_y²); tan(from) − 1e-9 ≤ s ≤ tan(to) + 1e-9
3D finishing toolpaths cam-finish.js32-bit in part- PartCraft
-
Finishing one straight line
The 3D points of a straight pass over the part, dense enough to stay within the tolerance.
split a span while |z(mid) − (z₀ + z₁) ÷ 2| > tol ÷ 2
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Thinning a pass
Drops points that lie on a straight run between their neighbors.
drop p when its distance to the line through the last kept point and the next point ≤ tol ÷ 10
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Parallel pass lines
The positions of the raster lines across the part at the chosen angle.
n = ceil((v₁ − v₀) ÷ (stepover × d) − 1e-9); line k at v₀ + (v₁ − v₀) k ÷ n
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Cusp height
The height of the ridge left between two ball passes a given distance apart on a flat surface.
h = R − √(R² − (s ÷ 2)²)
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Pass spacing for a cusp height
The distance between passes that leaves ridges of a given height.
s = 2 √(2 R h − h²); s = 2 R when h ≥ R
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Distance over the surface
The distance along the part's top surface from the starting cells to every other cell.
shortest path over grid steps; step length = √((di × c)² + (dj × c)² + ΔH²)
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Step directions of the distance search
The set of grid steps the surface-distance search may take.
all (di, dj) with |di|, |dj| ≤ 5 and no common factor
3D finishing toolpaths cam-finish.jsExact- PartCraft
-
Lines of equal surface distance
Traces the lines at a given surface distance, which become the scallop passes.
crossing on a cell edge at f = (level − a) ÷ (b − a)
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Scallop spacing and levels
The spacing of scallop passes from the cusp height, and the surface distances they are placed at.
R_b = ball or corner radius + leave; s = spacing(R_b, cusp); level k = (k + ½) s; grid cell = max(0.02, min(s ÷ 3, d ÷ 8))
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Simplifying a scallop pass
Reduces the points of a 3D pass while staying within a quarter of the tolerance.
keep the point farthest from the chord when its distance > tolerance ÷ 4, then repeat on both halves
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Tool grown by the stock to leave
Models stock to leave by making the cutter larger.
d′ = d + 2 × leave; corner radius′ = corner radius + leave (bull nose)
3D finishing toolpaths cam-finish.js64-bit- PartCraft
-
Simulation grid
Sets the cell size of the stock grid and the tolerances used to call a gouge.
cell = min(2, max(0.1, max(w, h) ÷ 500)); lateral tolerance = 2e-4 × diagonal + 0.01
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Cutting along a level move
Lowers the stock cells under one level move of the tool.
z_cell = min(z_cell, z + h(distance from cell center to the track))
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Cutting along a sloping move
Cuts a move that changes height as a series of short level moves.
n = ceil(|Δz| ÷ 0.01); piece i cut at the lower of its two end heights
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Stock volume
The volume of stock left, from which the volume removed by each operation is found.
V = cell² × Σ (z − stock bottom) over cells in the stock
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Part height with lateral tolerance
The part's height at a cell, taken as the lowest of the center and eight points a small distance round it.
min over the center and 8 points at the lateral tolerance, 45° apart
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Gouge detection
Finds cells where the stock was cut below the part's surface.
gouge when z_cell < eroded part height − 0.02
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Stock left and deepest gouge
The volume of stock left above the part, the thickest stock left and the deepest gouge.
remaining = cell² × Σ (z − max(part height, stock bottom)) where that exceeds 0.02
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Machining time
The time a program takes: cutting moves at their feed, rapid moves at the machine's rapid rate, plus tool changes.
seconds = 60 × (Σ L ÷ feed + Σ L ÷ rapid) + changes × change time
Stock simulation and machining time cam-sim.js64-bit- PartCraft
-
Arc center words I and J
The arc center written relative to the arc's start point.
I = round₃(c_x − round₃(start_x)); J = round₃(c_y − round₃(start_y))
G-code and toolpath exports cam-post.js64-bit- PartCraft
-
Axis words
Writes X, Y and Z only when they change at the output resolution.
write an axis when round₃(new) ≠ round₃(last written)
G-code and toolpath exports cam-post.js64-bit- PartCraft
-
Toolpath as CSV
Writes every segment's start, end, arc center, sweep and feed as text.
value = toFixed(6); sweep in degrees = sweep × 180 ÷ π
G-code and toolpath exports cam-post.js64-bit- PartCraft
-
Toolpath as JSON
Writes the setup, tools and every operation's moves.
JSON.stringify of the moves
G-code and toolpath exports cam-post.js64-bit- PartCraft
-
Spindle speed and feeds
The spindle speed, cutting feed, plunge feed and ramp feed for a tool.
rpm = round(1000 vc ÷ (π d)), limited to the machine's range; feed = rpm × flutes × f_z; plunge = feed ÷ 3; ramp = feed ÷ 2
Cutting speeds, feeds and tool profiles cam-tools.js64-bit- PartCraft
-
Rounding feeds to one decimal
Rounds a feed rate to tenths.
round1(v) = round(v × 10) ÷ 10
Cutting speeds, feeds and tool profiles cam-tools.js64-bit- PartCraft
-
Tool tip profile
The height of the cutting surface above the tool's tip at a given distance from its axis.
ball: R − √(R² − ρ²); bull: r_c − √(r_c² − (ρ − a)²) beyond a = R − r_c; drill and chamfer: (ρ − r_t) ÷ tan(angle ÷ 2); flat: 0
Cutting speeds, feeds and tool profiles cam-tools.js64-bit- PartCraft
-
Unit factors
The factor from the file's units to millimeters.
mm 1; cm 10; m 1000; in 25.4
Nested sheets from DXF to toolpaths cam-sheets.jsExact- PartCraft
-
Bulged segments to arcs
Turns a polyline with bulges into lines and true arcs.
r = (d ÷ 2)(1 + b²) ÷ (2|b|); offset = (d ÷ 2)(1 − b²) ÷ (2b); sweep = 4 atan(b)
Nested sheets from DXF to toolpaths cam-sheets.js64-bit- PartCraft
-
Extent of an outline
The box round a sheet or a part outline, used for sheet size and for placing parts on sheets.
min and max over points sampled along each piece at 0.05 chord tolerance
Nested sheets from DXF to toolpaths cam-sheets.js64-bit- PartCraft
-
Part coordinates on its sheet
Moves a part's points so its sheet's lower left corner is the origin, in millimeters.
x′ = (x − sheet x₀) × k; y′ = (y − sheet y₀) × k
Nested sheets from DXF to toolpaths cam-sheets.js64-bit- PartCraft
-
Elementary functions
The one-argument math functions a script can call: roots, exponentials, logarithms, trigonometry, hyperbolic functions, rounding and angle conversion.
log1p(x) = x − x² ÷ 2 + x³ ÷ 3 for |x| < 1e-4, else log(1 + x); asinh(x) = sign × log(|x| + √(x² + 1)); atanh(x) = ½ log((1 + x) ÷ (1 − x)); sind(x) = sin(x × π ÷ 180)
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Rounding to a number of decimals
round(x, d): rounds to d decimal places.
round(x × 10^d) ÷ 10^d
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Gamma function and factorial
Γ(x), and factorial(n) = Γ(n + 1).
whole x < 171: (x − 1)! by product; x < 0.5: π ÷ (sin(πx) Γ(1 − x)); else √(2π) t^(x − ½) e^(−t) Σ c_i ÷ (x − 1 + i), t = x + 6.5
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Binomial coefficient
nchoosek(n, k): the number of ways to choose k of n.
r ← r × (n − m + i) ÷ i for i = 1 … m, m = min(k, n − k); result = round(r)
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Spacing of numbers
eps(x): the gap between x and the next larger 64-bit number.
2^(floor(log₂|x|) − 52); eps(0) = 5e-324
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Evenly spaced values
linspace(a, b, n): n values from a to b.
value i = a + (b − a) × i ÷ (n − 1)
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Logarithmically spaced values
logspace(a, b, n): n values from 10^a to 10^b.
value i = 10 ^ (a + (b − a) × i ÷ (n − 1))
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Running sum and product
cumsum and cumprod along a dimension.
acc ← acc + x_k (or acc × x_k), stored at each step
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Variance and standard deviation
var and std of a set of values.
m = Σx ÷ n; var = Σ(x − m)² ÷ (n − 1), or ÷ n with weight 1; std = √var
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Median
The middle value of a set, or the mean of the two middle values.
sorted s; n odd: s[(n − 1) ÷ 2]; n even: (s[n ÷ 2 − 1] + s[n ÷ 2]) ÷ 2
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Dot product
dot(a, b): the sum of products of two vectors.
Σ a_i b_i
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Trapezoid integration
trapz(y) or trapz(x, y): the area under sampled data.
Σ (x_i − x_{i−1}) (y_i + y_{i−1}) ÷ 2
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
One-dimensional interpolation
interp1(x, y, xi): linear, nearest or previous-value interpolation in a table.
y = y_lo + (y_hi − y_lo)(q − x_lo) ÷ (x_hi − x_lo)
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Polynomial evaluation
polyval(p, x): the value of a polynomial.
s ← s × x + c for each coefficient (Horner)
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Polynomial fit
polyfit(x, y, n): the least-squares polynomial of degree n through data.
V_ij = x_i^(n − j); solve V p ≈ y
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
-
Matrix to text
mat2str(A): text that can be typed back in to recreate a matrix.
each value written with toPrecision(15) by default
CraftScript core math functions cs-lib-core.js64-bit- PartCraft
A calculation is added only after its source was read. Each statement can be checked in the code shown on its policy's page; the app repositories are public. When a release changes a calculation, its page says so until it has been read again.