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.

  • 6,917 calculations in 1,248 source files
  • 143 exact
  • 6,286 in 64-bit
  • 335 with a 32-bit step
  • Last reviewed

Calculations

  • Collapse cost

    The error of collapsing an edge to its midpoint.

    p = (P_a + P_b) ÷ 2; e = pᵀ·(Q_a + Q_b)·p = q₀x² + 2q₁xy + 2q₂xz + 2q₃x + q₄y² + 2q₅yz + 2q₆y + q₇z² + 2q₈z + q₉

    Decimate modifier mesh/modifiers.js
    • ModelCraft
    64-bit
  • Collapse test

    Decides whether the cheapest edge is collapsed now, put back with a new cost, or skipped.

    put back when e > e₀·(1 + 1e-9) + 1e-18; skip when (new normal)·(old normal) ≤ 0 for any triangle that stays

    Decimate modifier mesh/modifiers.js
    • ModelCraft
    64-bit
  • Sparse least squares (CGLS)

    Finds the unknowns that minimize |Ax − b| for a sparse set of rows.

    columns scaled by 1 ÷ |column|; stop when |Aᵀr|² ≤ tol²·max(1, |Aᵀr₀|²), tol = 1e-12

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • Conformal map (LSCM)

    UV positions for the corners of an island from the 2D shape of each of its triangles, with two points pinned.

    per triangle, with d = twice its signed area and s = 1 ÷ √|d|: Σⱼ Wⱼ·(uⱼ + i·vⱼ) = 0, W = s × the opposite edge vectors

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • Angle based flattening

    Corner angles close to the surface's own that a flat triangulation can have.

    minimize Σ (αᵢ − βᵢ)² ÷ βᵢ² subject to: each triangle sums to π, each inner wedge to 2π, Σ [ln sin α(next) − ln sin α(prev)] = 0 round each inner wedge

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • Preconditioned conjugate gradients

    Solves the constraint system of each Newton step of the angle based method.

    stop when r·r < 1e-14 × r₀·r₀

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • Corner angles of a triangle

    The three corner angles of a triangle in 3D.

    angle = acos(clamp(u·v ÷ (|u|·|v|), −1, 1))

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • A triangle's own 2D shape

    A triangle laid flat: A at the origin, B on the x axis, C where its side lengths put it.

    B = (|AB|, 0); C = (AC·x, AC·y), x = AB ÷ |AB|, y = unit((AB × AC) × AB)

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • A triangle's shape from its angles

    A flat triangle with the given corner angles, sized by the law of sines.

    A = (0, 0); B = (sin a₂, 0); C = (sin a₁·cos a₀, sin a₁·sin a₀)

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • Pinned points and first guess

    Chooses the two corners to pin and a starting layout for the solver.

    pins: the two ends along the longest box axis at (0, 0) and (d, 0), d = their distance in 3D

    UV unwrap solvers mesh/uv.js
    • ModelCraft
    64-bit
  • Closest point on a curve

    The parameter, point and distance of the point of a curve nearest a given point.

    f(u) = (C − P)·C′; u ← u − f ÷ (C″·(C − P) + C′·C′)

    NURBS lengths, areas, closest points and tessellation nurbs/curve.js
    • ModelCraft
    • PartCraft
    64-bit
  • Length of a curve

    The length of a curve, or of a part of it between two parameters.

    s = Σ pieces Σ₈ wᵍ·h·|C′(x₀ + h·(1 + xᵍ))|, 4 pieces per knot span

    NURBS lengths, areas, closest points and tessellation nurbs/curve.js
    • ModelCraft
    • PartCraft
    64-bit
  • Parameter at a length

    The parameter at which the curve has run a given length from its start.

    f(u) = length(a … u) − s; u ← u − f ÷ |C′(u)|, or the middle of the bracket

    NURBS lengths, areas, closest points and tessellation nurbs/curve.js
    • ModelCraft
    • PartCraft
    64-bit
  • Curve to polyline

    Points along a curve such that the curve stays within a tolerance of the chords between them.

    a segment is kept when the curve at 1/4, 1/2 and 3/4 of its parameter range lies within tol of the chord; else it is halved

    NURBS lengths, areas, closest points and tessellation nurbs/curve.js
    • ModelCraft
    • PartCraft
    64-bit
  • Are two curves the same

    Decides whether one curve lies on another within a tolerance.

    33 points of a, each within tol of its closest point on b

    NURBS lengths, areas, closest points and tessellation nurbs/curve.js
    • ModelCraft
    • PartCraft
    64-bit
  • Area of a surface

    The area of an untrimmed surface.

    A = Σ cells Σ₅ₓ₅ wₐ·w_b·h_u·h_v·|S_u × S_v|, 2 × 2 pieces per knot-span cell

    NURBS lengths, areas, closest points and tessellation nurbs/surface.js
    • ModelCraft
    • PartCraft
    64-bit
  • Closest point on a surface

    The (u, v), point and distance of the point of a surface nearest a given point.

    f = (S − P)·S_u, g = (S − P)·S_v; Newton on the 2 × 2 system with J = [S_u·S_u + r·S_uu, S_u·S_v + r·S_uv; ·, S_v·S_v + r·S_vv]

    NURBS lengths, areas, closest points and tessellation nurbs/surface.js
    • ModelCraft
    • PartCraft
    64-bit
  • Tessellation steps per knot span

    How many parameter steps each knot span gets so that the grid stays within the tolerance.

    n = ceil(h·√(M ÷ (4·tol))), 2 ≤ n ≤ maxPerSpan, M = largest |second derivative| at 5 × 7 sample points

    NURBS lengths, areas, closest points and tessellation nurbs/surface.js
    • ModelCraft
    • PartCraft
    64-bit
  • Surface to triangle grid

    A grid of points, normals and parameters on the surface with two triangles per cell.

    NURBS lengths, areas, closest points and tessellation nurbs/surface.js
    • ModelCraft
    • PartCraft
    64-bit
  • Deviation of points from a surface

    The largest, mean and root-mean-square distance of a set of points from a surface.

    dᵢ = closest-point distance; max; mean = Σ dᵢ ÷ n; rms = √(Σ dᵢ² ÷ n)

    NURBS lengths, areas, closest points and tessellation nurbs/analysis.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • Finding shared edges

    Finds pairs of surface edges that lie on each other.

    |L_A − L_B| ≤ max(10·tol, 0.05·max(L_A, L_B)); 7 points of A within tol of B

    Continuity between curves and between surfaces nurbs/continuity.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit
  • 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.js
    • ModelCraft
    • PartCraft
    64-bit

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.