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
-
Interpolating many lists at once
Control points for several point lists that share parameters, used for the columns of a loft or a curve network.
Curves through points nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Linear solve
Solves A·x = B for several right-hand sides.
Gaussian elimination with partial pivoting, then back-substitution
Curves through points nurbs/vec.js64-bit- ModelCraft
- PartCraft
-
Least-squares curve with given knots
The curve with given knots that is closest to a set of points, with its ends on the first and last point.
(NᵀN)·P = NᵀR, R = Q − N₀·Q₀ − Nₙ·Q(last)
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Least squares for many lists
The same fit for several point lists that share parameters and knots.
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Fitting a curve to a function
A curve within a tolerance of a parametric function, with as few control points as the refinement finds.
deviation = max |C(s) − f(s)| at the midpoints between fitting samples; count ← ceil(1.5·count) + 1 until deviation ≤ tol
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Fitting a surface to a function
A surface within a tolerance of a function of (u, v).
deviation = max of three sampled sets (between samples along u, along v, and at cell middles); the direction with the larger error gets ceil(1.5·n) + 1 control points
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Rebuilding a curve
A curve with a chosen number of control points and uniform knots that follows the original, with the deviation measured.
samples = max(4·count, 32); deviation = closest-point distance of the points midway between samples
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Deviation of points from a curve
The largest and mean distance of a set of points from a curve.
dᵢ = closest-point distance; max; mean = Σ dᵢ ÷ n
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/fit.js64-bit- ModelCraft
- PartCraft
-
Frames along a rail
A frame (origin, tangent and two cross directions) at each requested parameter of a rail, turning as little as possible.
double reflection: r reflected in the chord, then in the difference of tangents; then made square to the tangent
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Placing a profile in a frame
The profile's control points carried from the start frame to another frame, turned and scaled.
(a, b, z) = (d·r₀, d·s₀, d·t₀); (a, b) rotated by the twist; P′ = o + r·a·scale + s·b·scale + t·z·scale
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Sweep refinement
Lofts through placed sections and adds sections until the surface matches the true placement between them.
deviation = max |S(u, v_mid) − section(u)| at 13 points on each middle section; sections doubled until deviation ≤ tol
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Frame between two rails
The frame and the gap between two rails at a parameter, which place and scale the profile of a two-rail sweep.
X = (B − A) ÷ d, d = |B − A|; Z = unit(T₁ + T₂ − X·((T₁ + T₂)·X)); scale = d ÷ d₀
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Where two curves come closest
The parameters on two curves where they are nearest each other, and the distance there.
f = (A − B)·A′, g = −(A − B)·B′; Newton on the 2 × 2 system
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Monotone cubic interpolation
A smooth increasing map between a curve's own crossing parameters and the shared ones of a network.
interior slope = (w₁ + w₂) ÷ (w₁ ÷ δ₁ + w₂ ÷ δ₂), 0 where δ changes sign; cubic Hermite between nodes
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Surface through a network of curves
A Gordon surface through a grid of profile and guide curves.
S = L_u + L_v − T
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Coons patch
A surface filling four boundary curves that meet at their corners.
S = ruled(a, b) + ruled(l, r) − bilinear(corners)
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Offset surface
A surface at a distance from another along its normals.
target(u, v) = S(u, v) + n(u, v)·d, fitted within tol
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Rebuilding a surface
A surface with a chosen number of control points and uniform knots that follows the original, with the deviation measured.
samples = max(4·n, 16) each way; deviation = max |S′ − S| at the cell middles
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Extending a surface
Carries a surface on past an edge by a length measured across the edge at its middle.
the last span's polynomial evaluated by de Casteljau at t = (1 + du − last) ÷ (1 − last) > 1; du by secant steps until |length found − length| ≤ 1e-10·length
Fitted curves and surfaces: sweeps, networks, Coons patches, offsets, rebuilds and extensions nurbs/construct.js64-bit- ModelCraft
- PartCraft
-
Continuity class
Turns the measured gap, angle and curvature difference into G2, G1, G0 or none.
gap ≤ g0 → G0; and angle ≤ g1 → G1; and (dk ≤ g2 or rel ≤ g2rel) → G2
Continuity between curves and between surfaces nurbs/continuity.js64-bit- ModelCraft
- PartCraft
-
Join of two curves
The gap, the angle between tangents and the curvature difference where two curve ends meet.
gap = |P_a − P_b|; angle = atan2(|t_a × t_b|, t_a·t_b)·180 ÷ π; dk = |κN_a − κN_b|; rel = dk ÷ max(κ_a, κ_b)
Continuity between curves and between surfaces nurbs/continuity.js64-bit- ModelCraft
- PartCraft
-
Shared edge of two surfaces
Gap, normal angle and curvature difference at sample points along a shared edge, with the largest of each.
per sample: gap = |p_A − p_B|; angle between n_A and n_B; dk = |κ_A − κ_B| in the direction n_A × edge tangent
Continuity between curves and between surfaces nurbs/continuity.js64-bit- ModelCraft
- PartCraft
-
Values written into a problem
Rounds the measured gap, angle or curvature difference for a problem's found value and its text.
r4(x) = x rounded to 4 significant digits
Continuity between curves and between surfaces nurbs/continuity.js64-bit- ModelCraft
- PartCraft
-
Signed area of a loop
The signed area of a loop in the (u, v) plane; its sign tells which way the loop runs.
a = Σ (uᵢ·vᵢ₊₁ − uᵢ₊₁·vᵢ) ÷ 2
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Point inside a loop
Decides whether a (u, v) point is inside a loop.
count edges with (v_a > v) ≠ (v_b > v) and u < (u_b − u_a)·(v − v_a) ÷ (v_b − v_a) + u_a
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Do two segments cross
Decides whether two loop segments properly cross.
t, u = cross products ÷ d; crossing when 1e-12 < t < 1 − 1e-12 and 1e-12 < u < 1 − 1e-12
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Cleaning a loop
Checks a loop's points, clamps them to the patch and drops repeats.
refused when |area| < 1e-14·(u range)·(v range)
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Circle loop
A circular trim loop given by a center and radius as shares of the parameter range.
pointᵢ = [u_a + (u_b − u_a)·(u + r·cos aᵢ), v_a + (v_b − v_a)·(v + r·sin aᵢ)], aᵢ = 2π·i ÷ n
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Loop from a curve on the surface
Projects a closed 3D curve into the surface's (u, v) plane as a trim loop.
256 points of the curve, each → closest point (u, v) on the surface
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Moving loop points off grid lines
Shifts loop points that fall on a tessellation grid line, and keeps all of them inside the patch.
d = 1e-6 × parameter range; a point within d ÷ 2 of a grid line moves to line + d; every point is clamped to [start + d, end − d]
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Where a loop crosses the grid
The points where a loop segment crosses the tessellation's parameter lines.
t = (line − p) ÷ (q − p); point = p + t·(q − p)
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Triangulating a cut cell
Triangles for a polygon left in a grid cell after cutting.
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Area of the shown part
The area of a trimmed surface.
A = Σ |(b − a) × (c − a)| ÷ 2 over the triangles of the cut tessellation
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Area in the parameter plane
The area of the shown part in (u, v).
outer loop's area (or the whole domain) + Σ holes' signed areas
Trimmed surfaces: loops, cut tessellation and area nurbs/trim.js64-bit- ModelCraft
- PartCraft
-
Line buffer
The positions of a polyline in the host's units, for drawing.
Drawing NURBS curves and surfaces nurbs-ui/display.js32-bit, display only- ModelCraft
- PartCraft
-
Surface mesh buffers
The positions, normals, parameters and colors of a surface's triangles, for drawing.
Drawing NURBS curves and surfaces nurbs-ui/display.js32-bit, display only- ModelCraft
- PartCraft
-
Finding the sheet
The four corners of the paper in the photo.
corners = the pixels of the largest bright region with the smallest and largest x + y and x − y; photo position = (pixel + 0.5) × reduction factor
Sketch photo to drawing: sheet, perspective and scale photosketch/photosketch.js64-bit- ModelCraft
- CivilCraft
-
Perspective transform from four points
The 3 × 3 matrix that takes four points to four others.
8 equations in h₁…h₈ with h₉ = 1, solved by Gauss–Jordan elimination
Sketch photo to drawing: sheet, perspective and scale photosketch/photosketch.js64-bit- ModelCraft
- CivilCraft
-
Applying the perspective transform
A point taken through the 3 × 3 matrix.
w = h₆x + h₇y + h₈; x′ = (h₀x + h₁y + h₂) ÷ w; y′ = (h₃x + h₄y + h₅) ÷ w
Sketch photo to drawing: sheet, perspective and scale photosketch/photosketch.js64-bit- ModelCraft
- CivilCraft
-
Sheet proportions
The long-to-short ratio of the straightened sheet.
w = mean of top and bottom lengths, h = mean of left and right; r = max ÷ min; replaced by the named paper's ratio, or by the nearest standard ratio within 8 %
Sketch photo to drawing: sheet, perspective and scale photosketch/photosketch.js64-bit- ModelCraft
- CivilCraft
-
Drawing units per pixel
The size of one pixel of the straightened sheet in drawing units, and the mapping from pixels to drawing coordinates.
mm per px = long side in mm ÷ long side in px; units per px = mm per px × scale ÷ unit in mm; x = origin_x + px·k, y = origin_y + (height − py)·k
Sketch photo to drawing: sheet, perspective and scale photosketch/photosketch.js64-bit- ModelCraft
- CivilCraft
-
Arcs and circles into the drawing
Converts each traced arc to drawing units as a circle or as an arc through its start, middle and end.
r = r_px × units per px; circle when a₁ − a₀ ≥ 2π − 1e-6; else arc through start, middle (at (a₀ + a₁) ÷ 2) and end
Sketch photo to drawing: sheet, perspective and scale photosketch/photosketch.js64-bit- ModelCraft
- CivilCraft
-
Arc through three points
The center, radius and end angles of the arc through three points.
d = 2·(a_x(b_y − c_y) + b_x(c_y − a_y) + c_x(a_y − b_y)); center from the sums of |p|²·(differences) ÷ d; r = |a − center|
Sketch photo to drawing: sheet, perspective and scale photosketch/paper.js64-bit- ModelCraft
- CivilCraft
-
Placement matrix (classic files)
A component's placement as a 4 × 4 matrix from the file's 13 doubles.
rows of the 3 × 3 become columns; when w ≠ 1 every entry ÷ w
SKP import: placements, texture coordinates and face loops skp/legacy.js64-bit- ModelCraft
-
Texture coordinates (classic files)
The texture coordinates of each loop point of a textured face.
x_r = (−n_y, n_x, 0) ÷ |(n_x, n_y)|, y_r = n × x_r; (p_x, p_y) = (p·x_r, p·y_r); uv = (p_x, p_y, 1)·M⁻¹ ÷ q ÷ tile size
SKP import: placements, texture coordinates and face loops skp/legacy.js64-bit- ModelCraft
-
Loop normal
The Newell normal of a face loop, used to check which way round the loop runs.
n = Σ [(y_a − y_b)(z_a + z_b), (z_a − z_b)(x_a + x_b), (x_a − x_b)(y_a + y_b)]
SKP import: placements, texture coordinates and face loops skp/legacy.js64-bit- ModelCraft
-
Placement matrix (2021 and later files)
A component's placement as a 4 × 4 matrix from the file's 13 doubles.
k = 1 ÷ w; every rotation and translation entry × k
SKP import: placements, texture coordinates and face loops skp/vff.js64-bit- ModelCraft
-
Texture coordinates (2021 and later files)
The texture coordinates of a point on a textured face.
(p_x, p_y) = (p·x_r, p·y_r); without a placement: uv = (p_x ÷ tile width, p_y ÷ tile height); with one: (p_x, p_y, 1)·M⁻¹ ÷ q ÷ tile size
SKP import: placements, texture coordinates and face loops skp/vff.js64-bit- ModelCraft
-
Outer loop and loop direction
Chooses a face's outer loop and turns loops so that the outer runs counter-clockwise about the normal and holes clockwise.
area(loop) = Newell(loop)·unit normal ÷ 2; outer = loop with the largest |area|
SKP import: placements, texture coordinates and face loops skp/vff.js64-bit- ModelCraft
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.