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

  • Volume, center of mass and inertia from the mesh

    Mass properties of a closed triangle mesh at density 1.

    V = Σ a·(b × c) ÷ 6; ∫xxᵀ dV = Σ V_t ÷ 20 × (Σ pᵢpᵢᵀ + (Σpᵢ)(Σpᵢ)ᵀ); about the center: C − V g gᵀ

    Measuring and mass properties in 3D measure.js
    • PartCraft
    32-bit in part
  • Mass properties of a placed part

    Mass in grams and the inertia tensor in world axes for one placed part.

    I_world = (density ÷ 1000) × R I Rᵀ; center_world = M × center

    Measuring and mass properties in 3D measure.js
    • PartCraft
    64-bit
  • Mass properties of several parts together

    Total mass, combined center of mass and inertia tensor of an assembly.

    center = Σ mᵢ cᵢ ÷ Σ mᵢ; I = Σ (Iᵢ + mᵢ (|dᵢ|² E − dᵢ dᵢᵀ)), dᵢ = cᵢ − center

    Measuring and mass properties in 3D measure.js
    • PartCraft
    64-bit
  • Principal moments and axes

    The eigenvalues and eigenvectors of the inertia tensor.

    cyclic Jacobi rotations: t = sign(θ) ÷ (|θ| + √(θ² + 1)), θ = (a_qq − a_pp) ÷ (2 a_pq)

    Measuring and mass properties in 3D measure.js
    • PartCraft
    64-bit
  • Exact minimum distance

    The minimum distance between two picked faces, edges, points or bodies and the two closest points.

    Measuring and mass properties in 3D measure-brep.js
    • PartCraft
    64-bit
  • Exact volume, area, center and inertia

    Mass properties of the part's exact body at density 1.

    I_xy = I((x + y) ÷ √2) − (I_xx + I_yy) ÷ 2, and the same for yz and xz

    Measuring and mass properties in 3D measure-brep.js
    • PartCraft
    64-bit
  • Curved edges of an assembly drawing view

    Turns each visible or hidden curve of a hidden-line view into the line segments the drawing keeps.

    n = clamp(⌈span ÷ size × 160⌉, 8, 240) equal parameter steps

    Measuring and mass properties in 3D measure-brep.js
    • PartCraft
    64-bit
  • Sketch plane from a picked flat face

    The plane reference stored when a sketch is put on a picked flat face that has no stable name.

    o = each coordinate rounded to 9 decimals; n = each component rounded to 12 decimals

    Values stored from picks in the workspace partcraft.js
    • PartCraft
    64-bit
  • Mate plane from a picked face of an instance

    The plane stored in an assembly mate when a flat face of a placed part is picked.

    o rounded to 9 decimals, n to 12 decimals, when the face has no stable name

    Values stored from picks in the workspace partcraft.js
    • PartCraft
    64-bit
  • Anchor point on a drawing view

    The point in a view's own coordinates where a note, dimension or detail view is attached.

    u = u₀ + (x − x_view) ÷ scale, snapped to the nearest drawn line within 2.5 ÷ scale, then rounded to 4 decimals

    Values stored from picks in the workspace partcraft.js
    • PartCraft
    64-bit
  • Default section plane offset

    The offset of a new section view's cutting plane: the middle of the part's bounding box along the view direction.

    offset = dir · (min + max) ÷ 2, rounded to 4 decimals

    Values stored from picks in the workspace partcraft.js
    • PartCraft
    64-bit
  • Arc through three points

    Center, radius, start angle and signed sweep of an outline arc given by its start, middle and end.

    c_x = (|a|²(m_y − b_y) + |m|²(b_y − a_y) + |b|²(a_y − m_y)) ÷ d, d = 2 (a_x(m_y − b_y) + m_x(b_y − a_y) + b_x(a_y − m_y))

    Circuit board outline, holes and part boxes kicad.js
    • PartCraft
    64-bit
  • Arc as straight segments

    The points that replace an arc or circle of the board outline.

    steps = max(2, ⌈|sweep| ÷ 7.5°⌉); pₖ = c + r (cos aₖ, sin aₖ), aₖ = a₀ + sweep × k ÷ steps

    Circuit board outline, holes and part boxes kicad.js
    • PartCraft
    64-bit
  • Joining outline pieces into loops

    Chains lines and arcs of the edge layer into closed outlines.

    Circuit board outline, holes and part boxes kicad.js
    • PartCraft
    64-bit
  • Footprint point on the board

    Moves a point of a footprint (a pad, a corner of its box) to board coordinates.

    x = at_x + l_x cos a − l_y sin a; y = −at_y + l_x sin a + l_y cos a; l_y = −p_y, a = rotation × π ÷ 180

    Circuit board outline, holes and part boxes kicad.js
    • PartCraft
    64-bit
  • Board thickness parameter

    The part parameter that drives the board's extrusion depth.

    board_t = thickness rounded to 4 decimals

    Circuit board outline, holes and part boxes kicad.js
    • PartCraft
    64-bit
  • Binary STL coordinates

    Reads the corner coordinates of each triangle from a binary STL file.

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • 3MF vertex placement

    Applies the unit of each model file and the chain of build and component transforms to every vertex.

    p′ = [x s, y s, z s, 1] × M (row vectors, 4 × 3); s = unit of the part file ÷ unit of the root file

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Welding coincident points

    Merges points that lie within a tolerance of each other and maps every index to the point that is kept.

    merge when (Δx² + Δy² + Δz²) ≤ tol²; the earliest point is kept

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Repair tolerances from the mesh size

    Sets the weld distance, the gap-closing distance and the smallest triangle area kept, then welds and cleans.

    exact = 1e-7 × size; gap = 1e-3 × size; area limit = 1e-14 × size²; size = bounding-box diagonal

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Closing small gaps

    Merges boundary points that lie within the gap distance of another boundary point.

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Outward orientation by signed volume

    Turns each closed shell so that it encloses positive volume.

    6 V = Σ (a − o)·((b − o) × (c − o)), o = the shell's first point

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Filling a hole

    Closes a boundary loop with triangles.

    Newell normal n = Σ ((a_y − b_y)(a_z + b_z), …); ear when cross(a, b, c) > 0 and no other point is inside

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Growing flat faces

    Joins neighboring triangles into one flat face when they share a plane.

    join when n_s·n_t ≥ cos 0.05° and every corner of t is within tol of s's plane; tol = 2e-6 × size + 1e-7

    Mesh import, repair and storage meshimport.js
    • PartCraft
    64-bit
  • Plane of a flat face

    The normal and origin of each flat face a sketch can sit on.

    n = unit(Σ n_t A_t); origin = Σ (triangle center × A_t) ÷ Σ A_t

    Mesh import, repair and storage meshimport.js
    • PartCraft
    32-bit in part
  • Mesh kept in the part file

    Packs the repaired mesh into the text the part file stores.

    vertices → Float32Array → base64

    Mesh import, repair and storage meshimport.js
    • PartCraft
    32-bit in part
  • Mesh read back from the part file

    Unpacks and checks the stored mesh when a part is opened or rebuilt.

    Mesh import, repair and storage meshimport.js
    • PartCraft
    32-bit in part
  • Permeability of free space

    The constant μ₀ used for air, linear materials and the Maxwell stress.

    μ₀ = 4 × 10⁻⁷ × π

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Reluctivity from a measured B–H curve

    Turns a table of B and H points into ν(B²) and its derivative for the solver.

    H(B) by a monotone cubic through the points; beyond the last point H = H_s + (B − B_s) ÷ μ₀; ν = H ÷ B; dν/dB² = (H′ ÷ B − H ÷ B²) ÷ (2B)

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Banded Cholesky solve

    Factors the tangent matrix and solves for the correction of the potential.

    K = L Lᵀ in band storage; forward then back substitution

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Triangle areas and shape-function gradients

    The area, center and the three gradient vectors of every triangle.

    d = (x₁ − x₀)(y₂ − y₀) − (x₂ − x₀)(y₁ − y₀); area = |d| ÷ 2; ∇Nᵢ = (bᵢ, cᵢ) ÷ d

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Residual and tangent matrix

    Assembles the out-of-balance load and, when asked, the tangent stiffness for the current potential.

    R = load − Σ ν A (∇Nᵢ·∇A); K_ik = Σ A (ν ∇Nᵢ·∇N_k + 2ν′ (∇Nᵢ·∇A)(∇N_k·∇A))

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Newton iteration

    Repeats solve and update until the potential stops changing.

    A ← A + α ΔA, α halved until the residual norm falls; stop when |ΔA| ÷ |A| < tol or |R| < 1e-14 × |load|

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Flux density and energy per element

    The flux density in each triangle and the stored energy per unit depth.

    B = (∂A/∂y, −∂A/∂x); |B| = hypot; energy = Σ ½ ν(|B|²) |B|² × area

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Force and torque by the Maxwell stress

    The force per meter of depth and the torque about the origin on everything inside a set of elements.

    t = ((B_x² − ½B²) n_x + B_x B_y n_y, B_x B_y n_x + (B_y² − ½B²) n_y) ÷ μ₀; F = Σ t × dl; τ = Σ (x t_y − y t_x) dl

    Magnet study: 2D field, force and torque magnet.js
    • PartCraft
    64-bit
  • Sketch regions in SI units

    Converts each profile to meters and sets its material, magnet direction or coil current density.

    x_m = x_mm × 1e-3; area_m² = area_mm² × 1e-3 × 1e-3; B_r = B (cos θ, sin θ); J = I ÷ area

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Mesh sizes for the study

    The triangle size asked for in each body, in each air gap and in the surrounding air.

    base = size × (1 + 2 pad) ÷ 14 ÷ q; body: narrowest side ÷ 5 ÷ q; gap: gap ÷ 4 ÷ q

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Air gap between two bodies

    The narrowest distance between two profiles that stand apart.

    d = min over the corners of each profile of the distance to the other's edges

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Force and torque on each body

    The force in newtons and the torque about the body's own center, for the depth given.

    F = F_per_m × depth; τ = (τ_origin − (c_x F_y − c_y F_x)) × depth

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Results as CSV

    Writes the peak flux density, forces and torques to a CSV file.

    number → toPrecision(8)

    Magnet study: 2D field, force and torque magnet-study.js
    • PartCraft
    64-bit
  • Orientation test

    Which side of a directed line a point lies on, used to walk the triangulation.

    (b_x − a_x)(c_y − a_y) − (b_y − a_y)(c_x − a_x)

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • In-circle test

    Whether a new point lies inside the circle through a triangle's corners, which decides the Delaunay cavity.

    3 × 3 determinant of (a − d, b − d, c − d) with their squared lengths

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Circumcenter and quality of a triangle

    A triangle's circumcenter, circumradius and shortest edge, used to decide whether to refine it.

    u = (c_y |b|² − b_y |c|², b_x |c|² − c_x |b|²) ÷ (2 (b_x c_y − b_y c_x)), b and c relative to a

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Encroached boundary segment

    Whether a point lies inside the circle whose diameter is a boundary segment, in which case the segment is split at its midpoint.

    (p − mid)² < (|a − b|² ÷ 4) × (1 − 1e-12)

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Smallest and largest mesh angle

    The mesh quality figures shown with the result.

    angle = atan2(|u × v|, u·v) in degrees

    Magnet study: 2D field, force and torque magnetmesh.js
    • PartCraft
    64-bit
  • Coarse element matrix

    Forms Rᵀ K R for one fine element inside a coarse element.

    K_coarse += s × Rᵀ K R

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Inverse of each node's 3 × 3 block

    Inverts the diagonal block of every node for the block Jacobi smoother.

    D⁻¹ = adj(D) ÷ det(D)

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Damped block Jacobi sweep

    One smoothing step on a level.

    x ← x + ω D⁻¹ (b − A x), ω = 0.6

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Restriction and prolongation

    Moves residuals to the coarser grid and corrections back to the finer one.

    weight = ½ for each direction in which the fine node lies between two coarse nodes

    Geometric multigrid for the voxel stress model mg.js
    • PartCraft
    64-bit
  • Coarsest-level factorization

    Factors the coarsest level's matrix once so each cycle can solve it directly.

    A = L Lᵀ in band storage, nodes renumbered with the longest axis slowest

    Geometric multigrid for the voxel stress model mg.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.