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

  • Sketch curves as kernel edges

    Turns the lines, arcs, circles and splines of a sketch into the kernel's edges for a loft.

    arc: start, middle and end points c + r × (cos, sin) at a₀, a₀ + sweep ÷ 2, a₀ + sweep, then an arc through the three points

    Surface features built with the kernel surface.js
    • PartCraft
    64-bit
  • Network surface as a kernel face

    Hands the surface fitted through a network of curves to the kernel and sets the tolerance its seams are sewn with.

    face tolerance 1e-9; sewing tolerance = max(1e-7, 1e-7 × size)

    Surface features built with the kernel surface.js
    • PartCraft
    64-bit
  • Area of a surface body

    The area of each surface body left after a rebuild.

    area = Σ over the faces of OpenCascade's surface area

    Surface features built with the kernel surface.js
    • PartCraft
    64-bit
  • Display mesh of a surface body

    The triangles used to draw each surface body.

    linear deflection = 2e-4 × diagonal; angular deflection = 2π ÷ 64

    Surface display meshes, curvature map and zebra stripes surface.js
    • PartCraft
    32-bit, display only
  • Curvature per vertex

    The discrete Gaussian and mean curvature at each vertex of a triangle mesh, for the curvature map.

    K = (2π − Σ angles) ÷ A; H = |Σ (cot α + cot β)(pᵢ − pⱼ)| ÷ 4A, A = one third of the area of the triangles at the vertex

    Surface display meshes, curvature map and zebra stripes surface.js
    • PartCraft
    32-bit, display only
  • Zebra stripe value

    Whether a surface normal reflects a light or a dark stripe.

    r = d − 2(d · n)·n; stripe = ⌊(atan2(r_x, r_z) ÷ π + 1) × stripes ÷ 2⌋ mod 2

    Surface display meshes, curvature map and zebra stripes surface.js
    • PartCraft
    32-bit, display only
  • Basis functions and derivatives

    The B-spline basis functions and their derivatives at a parameter.

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Point and derivatives of a NURBS curve

    A rational curve's point and first two derivatives at a parameter.

    C = A ÷ w; C′ = (A′ − w′·C) ÷ w; C″ = (A″ − 2w′·C′ − w″·C) ÷ w

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Point and derivatives of a line, circle or ellipse

    A profile curve's point and first two derivatives at a parameter.

    circle and ellipse: C = c + a·cos t·x + b·sin t·y

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Point and derivatives of a B-spline surface

    A B-spline surface's point and all derivatives up to second order at (u, v).

    homogeneous sums A[k][l] = Σ Nᵤ⁽ᵏ⁾·Nᵥ⁽ˡ⁾·w·P; S[k][l] by the quotient rule with binomial factors 1, 2, 1

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Closest point on a sphere, torus or cone

    The nearest point, the normal there and the distance, in closed form.

    sphere: c + r·n̂, d = | |p − c| − r |; torus: tube center m = c + R·ê, then m + r·n̂; cone: τ = ((ρ − r₀)·k + t) ÷ (1 + k²)

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • One-dimensional Newton minimizer

    Refines the parameter of the nearest point on a profile curve.

    Δt = −f′ ÷ f″ (or one sample spacing downhill when f″ ≤ 0); stop when |Δt| ≤ 1e-15 × (|b − a| + |t|)

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Start points for the minimizer

    Samples the distance along a curve and runs Newton from the two best samples.

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Closest point on a surface of revolution

    The nearest point on a profile turned about an axis.

    minimize ½((ρ(v) − ρ_p)² + (t(v) − t_p)²) over the profile parameter v

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Closest point on an extruded surface

    The nearest point on a curve swept along a direction.

    minimize ½ |across(p − C(u))|²; P = C(u) + ((p − C(u)) · d)·d

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Closest point on a B-spline surface

    The nearest point on a B-spline face, kept inside the face's parameter box.

    Newton on ∇½|S(u, v) − p|² = 0 with the Hessian [Sᵤ·Sᵤ + Sᵤᵤ·r, Sᵤ·Sᵥ + Sᵤᵥ·r; …]

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Smallest radius of curvature near a point

    The radius of curvature the mesher uses to size elements on a curved face.

    sphere, torus: r; cone: ρ × √(1 + k²); else 1 ÷ max |Δn| ÷ moved over three directions 60° apart

    Exact surfaces for the tetrahedral mesher surfaces.js
    • PartCraft
    64-bit
  • Sketch plane from the file

    Reads a sketch plane's origin, normal and x direction and checks that x lies in the plane.

    |x̂ · n̂| ≤ 1e-6

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Sketch points into the part's plane

    Builds the file's sketch frame and maps each sketch point into the frame of the plane the sketch is put on.

    x = unit(x − n·(x · n)); y = n × x; (u, v) → world = o + u·x + v·y → plane = ((w − o′) · x′, (w − o′) · y′)

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Distance from a point to a segment

    The distance from a position to a straight piece of an edge.

    t = clamp((p − a) · (b − a) ÷ |b − a|², 0, 1); d = |p − (a + t·(b − a))|

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Nearest edge to a stored position

    Finds which edge of the part built so far a fillet or chamfer in the file refers to, and how far the stored position is from it.

    minimum over the edge polyline segments of the point-to-segment distance

    Import of a parametric export file swimport.js
    • PartCraft
    32-bit in part
  • Distance from a point to a triangle

    The distance from a position to one display triangle of a face.

    inside the triangle: |(p − a) · n̂|; else the least distance to its three sides

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Nearest face to a stored position

    Finds which face of the part built so far a feature in the file refers to.

    minimum over the display triangles of the point-to-triangle distance

    Import of a parametric export file swimport.js
    • PartCraft
    32-bit in part
  • Flat face lying in a sketch's plane

    Looks for a named flat face of the part in the plane a sketch was drawn on, so the sketch can follow that face.

    | |n_face · n| − 1 | < 1e-9 and |(o − o_face) · n_face| < 1e-7 × max(1, |o|)

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Base plane and world axis tests

    Decides whether a plane is one of the three base planes.

    | |n̂ · n_base| − 1 | < 1e-9 and |o · n_base| < 1e-9 × max(1, |o|)

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Dimension turned into a parameter

    Gives a dimension that other equations use a parameter of its own, holding its value.

    expression text = formatNumber(value) (12 significant digits, expr.js)

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Equation result against the stored value

    Warns when an imported equation would give a different number from the value the file holds.

    |v − held| > 1e-6 × max(1, |held|)

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Volume check

    Compares the volume of the rebuilt part with the volume recorded in the file.

    same when |V − V_file| ≤ 1e-4 × max(1, V_file)

    Import of a parametric export file swimport.js
    • PartCraft
    64-bit
  • Number formatter

    Writes one number as macro text.

    text = toPrecision(v, 15); |v| < 1e-14 → 0

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Millimeters to meters

    Converts a length or a coordinate from millimeters to the meters the macro uses.

    m = round(mm × 10⁶) ÷ 10⁹

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Degrees to radians

    Converts an angle in degrees to the radians the macro uses.

    rad = deg × π ÷ 180

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Unit-vector component

    Writes a component of a sketch plane's normal or x direction.

    u = round(v × 10¹²) ÷ 10¹²

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Sketch dimension value and text position

    Works out the value of each sketch dimension in meters or radians and where its text sits.

    length: value ÷ 1000; angle: value × π ÷ 180; arc radius = |start − center|

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Pick point on a face

    Finds a point inside a face, used by the macro to select that face.

    centroid of the largest triangle = (a + b + c) ÷ 3, moved onto the plane: p − ((p − o)·n) n

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Countersink depth and taper

    The depth and half angle of the tapered cut that stands in for a countersink.

    depth = (D − d) ÷ 2 ÷ tan(angle × π ÷ 360); taper = angle ÷ 2 × π ÷ 180

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Expected volume and box after each step

    Writes the part's volume and bounding box after a feature, for the macro to compare with what it built.

    volume in m³ = volume in mm³ × 10⁻⁹; box corners through the millimeter-to-meter conversion

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Body check tolerances in the macro

    The comparison the macro makes between the body it built and the expected volume and box.

    |v − vol| ≤ 10⁻⁴ × |vol| + 10⁻¹⁵; |box − expected| ≤ 10⁻⁵ m + 0.02 × diagonal

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Final volume comparison

    Writes the finished part's volume into the macro and the test that reports whether the rebuilt part matches.

    |v − vol| ≤ 10⁻⁴ × vol, v = reported volume × 10⁹ (mm³)

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • Numbers in equations

    Writes a parameter expression as equation text for the macro, including its numeric constants.

    constant → formatNumber(value); pow(a, b) → (a) ^ (b); log(x) → log(x) ÷ log(10)

    Numbers written into the VBA macro export swmacro.js
    • PartCraft
    64-bit
  • 64-point rule on the tetrahedron

    Builds the integration points and weights used for mass and body loads.

    x = u, y = v(1 − u), z = w(1 − u)(1 − v); weight = wₐ w_b w_c ÷ 8 × (1 − u)² (1 − v)

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Shape functions of the 10-node tetrahedron

    The ten shape functions and their derivatives at a point of the element.

    corner: N = L(2L − 1); midside: N = 4 LᵢLⱼ

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Jacobian and physical derivatives

    The element's Jacobian determinant at a point and the shape-function derivatives in x, y and z.

    J = Σ xₐ ∂Nₐ/∂ξ; det J by cofactors; ∂N/∂x = J⁻ᵀ ∂N/∂ξ

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Element stiffness

    The 30 × 30 stiffness matrix of one element and its volume.

    Kₑ = Σₚ wₚ det Jₚ E · Bᵀ D B; volume = Σₚ wₚ det Jₚ

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Element mass and shape-function integrals

    The consistent mass matrix of one element and ∫N dV for each node, used for gravity.

    Mₑ = Σₚ ρ wₚ det Jₚ NₐN_b; ∫Nₐ dV = Σₚ wₚ det Jₚ Nₐ

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Stress and strain at a Gauss point

    The six strains and six stresses at one Gauss point from the element's displacements.

    ε = B u; σ = E · D (ε − α ΔT [1 1 1 0 0 0])

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • 6-point rule on a triangle face

    The points and weights used to integrate loads, areas and heat exchange over boundary faces.

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Shape functions of the 6-node face

    The six shape functions of a boundary face and their derivatives.

    corner: N = L(2L − 1); midside: N = 4 LᵢLⱼ

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Integration over a boundary face

    The area-weighted normal and position at each rule point of a curved boundary face.

    n dA = (∂x/∂L₁ × ∂x/∂L₂) × w ÷ 2

    Quadratic tetrahedron element matrices tetfea.js
    • PartCraft
    64-bit
  • Area element on a face for heat terms

    The area weight at each rule point of a 6-node face, for heat exchange and heat loads.

    dA = |∂x/∂L₁ × ∂x/∂L₂| × w ÷ 2

    Quadratic tetrahedron element matrices tet-elements.js
    • PartCraft
    64-bit
  • Element conductivity matrix

    The 10 × 10 heat conduction matrix of one element.

    Kₑ = Σₚ wₚ det Jₚ k ∇Nₐ·∇N_b

    Quadratic tetrahedron element matrices tet-elements.js
    • 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.