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
-
Signed distance from a point to a line
How far a point is from a line through two points, positive on the left.
s = (Δx·(p_y − a_y) − Δy·(p_x − a_x)) ÷ |b − a|
Sketch geometry and measured values sketch.js64-bit- PartCraft
-
Nearly parallel test
Decides whether two lines are close enough to parallel to take a distance instead of an angle.
|u × v| ÷ (|u| × |v|) < 1e-6
Sketch geometry and measured values sketch.js64-bit- PartCraft
-
Sketch fillet
Trims two lines at a corner and adds a tangent arc of a given radius between them.
θ = acos(u₁ · u₂); d = r ÷ tan(θ ÷ 2); tangent points = P + uᵢ × d; center = P + bisector × r ÷ sin(θ ÷ 2)
Sketch geometry and measured values sketch.js64-bit- PartCraft
-
Size of a sketch
The largest coordinate size in a sketch, which the tolerances of the sketch code are scaled by.
extent = max(|x|, |y| over the points; |c_x| + r, |c_y| + r over the circles)
Sketch geometry and measured values sketch.js64-bit- PartCraft
-
Box of a sketch
The bounding box of the sketch geometry.
Sketch geometry and measured values sketch.js64-bit- PartCraft
-
Points along an arc
An arc as a run of points from its start to its end.
n = max(1, ⌈sweep ÷ 2π × segFull − 1e-9⌉); pointᵢ = c + r × (cos(a₀ + sweep·i ÷ n), sin(…))
Sketch profiles as closed polygons sketch.js64-bit- PartCraft
-
Points around a circle
A circle as a closed polygon with its corners on the circle.
pointᵢ = c + r × (cos(2π·i ÷ n), sin(2π·i ÷ n))
Sketch profiles as closed polygons sketch.js64-bit- PartCraft
-
Closed loops of a sketch
Chains the sketch's curves into closed loops, or reports an open end or a branch.
ends are one node when closer than 10 × tol, tol = 1e-6 × max(1, extent)
Sketch profiles as closed polygons sketch.js64-bit- PartCraft
-
Point inside loops
Tests whether a point lies inside a set of loops by the even-odd rule.
count edges with (a_y > p_y) ≠ (b_y > p_y) and p_x < (b_x − a_x)·(p_y − a_y) ÷ (b_y − a_y) + a_x
Sketch profiles as closed polygons sketch.js64-bit- PartCraft
-
Area of a loop
The signed area of a polygon loop.
area = ½ × Σ (xⱼ·yᵢ − xᵢ·yⱼ)
Sketch profiles as closed polygons sketch.js64-bit- PartCraft
-
Jacobian by central differences
The rate of change of every relation's residual with each variable it depends on.
∂f/∂x ≈ (f(x + h) − f(x − h)) ÷ 2h, h = 1e-6 × max(1, |x|)
Sketch solver solver.js64-bit- PartCraft
-
Cholesky solve
Solves the symmetric system of each Newton step.
A = L·Lᵀ; L·y = b; Lᵀ·z = y
Sketch solver solver.js64-bit- PartCraft
-
Damped Newton iteration
Repeats least-norm steps until every residual is within the tolerance.
dx = Jᵀ · (J·Jᵀ + μ·max(scale, 1e-12)·I)⁻¹ · (−r); x ← x + α·dx, α halved until Σr² falls
Sketch solver solver.js64-bit- PartCraft
-
Solving a sketch
Solves the sketch in place and classifies it as under, fully or over defined.
tol = 1e-9 × max(1, extent)
Sketch solver solver.js64-bit- PartCraft
-
Writing the solution back
Copies the solved variables to the sketch's points, radii and spline end angles.
angle ← atan2(sin a, cos a)
Sketch solver solver.js64-bit- PartCraft
-
Rank, redundancy and determined geometry
Counts the degrees of freedom left, names relations that repeat or conflict, and marks which entities are fully defined.
dof = variables − rank; row redundant when its remainder after projection is under 1e-7; variable determined when Σ q_k² > 1 − 1e-6
Sketch solver solver.js64-bit- PartCraft
-
Residual: an arc's two ends on one radius
The equation that keeps an arc's end point at the same distance from the center as its start point.
f = |e − c| − |s − c|
Sketch solver sketch.js64-bit- PartCraft
-
Residuals: parallel and perpendicular
The equations for two lines being parallel or square to each other.
parallel: (u × v) ÷ (|u|·|v|); perpendicular: (u · v) ÷ (|u|·|v|)
Sketch solver sketch.js64-bit- PartCraft
-
Residuals: tangent
The equations for a line touching a circle or arc, and for two circles or arcs touching.
shared end, line and arc: (u · (p − c)) ÷ (|u|·r); shared end, two arcs: ((p − a) × (p − b)) ÷ (rₐ·r_b); else: ±dist(c, line) − r, or d − (rₐ + r_b), or d − ±(rₐ − r_b)
Sketch solver sketch.js64-bit- PartCraft
-
Residuals: distance dimensions
The equations that hold a distance between two points, the length of a line, or the distance from a point or a line to a line.
f = |b − a| − value; f = sign × signed distance − value
Sketch solver sketch.js64-bit- PartCraft
-
Residual: angle dimension
The equation that holds the angle between two lines at a value in degrees.
f = atan2(u × v, u · v) − sign × value × π ÷ 180, wrapped to (−π, π]
Sketch solver sketch.js64-bit- PartCraft
-
Typed text to a number
Reads a typed size such as 12.5, ⌀20, R5, 30° or 12 mm as a number.
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Value shown in the input box
Opens the input box at a value for the person to accept or change.
box text = fmt(value) (at most 4 decimals)
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Applying the typed value
Takes the text of the input box when it closes and hands the number to whatever asked for it.
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Changing a dimension's value
Stores the typed number as the dimension's value.
0 ≤ value; angle ≤ 180; radius and diameter > 0
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Keeping a typed size
Checks a size typed while drawing and keeps it for the shape.
angle ← ((v mod 360) + 360) mod 360; sweep must be in (0, 360); other sizes > 0
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Point from typed sizes
Where the typed length and angle, width and height, diameter, radius or sweep put the next point of the shape being drawn.
line: a + (cos r, sin r) × len, r = angle × π ÷ 180; rectangle: a ± (w, h); arc end: c + R(sweep) · (s − c)
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Snap to horizontal or vertical
Makes a line drawn within 3° of horizontal or vertical exactly so.
angle° = |atan2(Δy, Δx)| × 180 ÷ π; within 3° of 0, 180 or 90: copy the start's y or x to the end
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Point snapped onto a curve
The nearest point on a line, circle, arc or spline to the pointer, used when a new point snaps onto a curve.
line: a + t·d, t = ((p − a) · d) ÷ (d · d); circle: c + (p − c) × r ÷ |p − c|
Sketch editor: typed sizes and dimension values sketchview.js64-bit- PartCraft
-
Sketch coordinates to canvas pixels
Maps a sketch point to its place on the canvas.
x = w ÷ 2 + (u − c_x) × s; y = h ÷ 2 − (v − c_y) × s
Sketch editor drawing sketchview.js32-bit, display only- PartCraft
-
Dimension lines and label
The lines, arcs, arrowheads and text of a dimension as drawn.
label text = fmt(value, 3)
Sketch editor drawing sketchview.js32-bit, display only- PartCraft
-
Normal distribution tail
The probability that a standard normal value exceeds z, used for the share of assemblies outside a limit.
P(Z > z) = ½ × erfc(z ÷ √2); erfc(x) ≈ k × exp(−x² − 1.26551223 + k·(1.00002368 + …)), k = 1 ÷ (1 + ½|x|)
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Stack-up analysis
The gap's nominal and mean, its worst-case and statistical limits, each link's share and rank, and the check against the limits.
a = sign × sens; m = nominal + (up + lo) ÷ 2; t = (up − lo) ÷ 2; WC = Σ|a|·t; RSS = √Σ(a·t)²; σ = RSS ÷ 3; ppm = (P_below + P_above) × 10⁶
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Links from picked points
Makes the links of a chain from points picked in order, measured along one direction.
Δs = d · b − d · a; nominal = round(|Δs|, 9 decimals); sign = sign of Δs
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Rounding of measured nominals
Rounds a measured length or direction component before it is stored on a link.
round(v) = Math.round(v × 10⁹) ÷ 10⁹
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Vector stack projected on a direction
Turns a chain whose links run in different directions into a one-direction chain along an output direction, with each link's angular swing as an extra link.
sens = (u · d) × sens; swing: c = nominal × ((axis × u) · d); up, lo = c × angle° × π ÷ 180
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Vector stack analysis
The nominal gap as a vector and its length, and the analysis along each output direction and along the gap itself.
gap = Σ sign × nominal × u; |gap| = √(g_x² + g_y² + g_z²)
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Links from picked points in 3-D
Makes links that run straight from each picked point to the next.
nominal = round(|b − a|, 9 decimals); dir = round((b − a) ÷ |b − a|, 9 decimals)
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Tolerance from a feature control frame
How a geometric tolerance enters a stack: plus and minus half the tolerance zone.
up = tol ÷ 2; lo = −tol ÷ 2
Tolerance stack-ups stackup.js64-bit- PartCraft
-
General tolerance for a nominal size
The deviation a title block's general tolerance gives one nominal size: a class of ISO 2768-1, or a typed ± value.
class f, m, c or v: the table row for the first range with nominal ≤ upper end (0.5 to 4000 mm); typed: parseFloat of the number after ±
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Stack-up as CSV
Writes the links and the results of a stack-up to a CSV file.
every number written as +v.toFixed(4)
Tolerance stack-ups stackup.js64-bit- PartCraft
-
Sizes of a template
One row of parameter values (mm) per size of a standard part family.
value = Number(value.toFixed(4))
Standard part templates stdparts.js64-bit- PartCraft
-
Hexagon across flats
Draws a hexagon from its across-flats size and holds that size with a dimension.
e = s × 2 ÷ √3; first corner at (e ÷ 2, 0)
Standard part templates stdparts.js64-bit- PartCraft
-
Circle of a given diameter
Draws a circle about the origin and holds its diameter with a dimension.
r = d ÷ 2
Standard part templates stdparts.js64-bit- PartCraft
-
Parallel key outline
The round-ended outline of a parallel key from its width and length.
half = (l − b) ÷ 2; center distance = l − b; end radius = b ÷ 2
Standard part templates stdparts.js64-bit- PartCraft
-
Patch through boundary edges
A surface that fills a closed loop of edges, optionally tangent to the faces next to it.
MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
Surface features built with the kernel surface.js64-bit- PartCraft
-
Loft through wires
A surface or solid through a series of curves in order.
ThruSections(solid, ruled, 1e-6)
Surface features built with the kernel surface.js64-bit- PartCraft
-
Thickening a surface
Turns a surface body into a solid of a given thickness on one side or half on each side.
both sides: offset the sheet by −t ÷ 2, then thicken by t; in: thicken by −t
Surface features built with the kernel surface.js64-bit- PartCraft
-
Offsetting a surface
A new surface at a distance along the normals of an existing one.
MakeOffsetShape.PerformBySimple(sheet, d)
Surface features built with the kernel surface.js64-bit- PartCraft
-
Stitching surfaces
Sews surface bodies together along their edges, into a solid when they close.
edges closer than tol are joined; tol = 0.01 by default
Surface features built with the kernel surface.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.