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

  • Torus

    The point at two angles on a torus, and the inverse.

    c = R + r cos v; S(u, v) = o + c cos u · x + c sin u · y + r sin v · z

    STEP curves and surfaces: points from parameters step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Surface of revolution

    The point of a profile curve turned about an axis by an angle, and the inverse.

    S(u, v) = o + h z + rr cos u + (z × rr) sin u, h = (C(v) − o)·z, rr = (C(v) − o) − h z

    STEP curves and surfaces: points from parameters step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Angle of a point on an ellipse

    The ellipse parameter of the point on the ellipse nearest a given point.

    f(t) = (E(t) − q)·E′(t) = 0, solved by t ← t − f ÷ f′

    STEP curves and surfaces: parameters from points step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Parameter of a point on a B-spline curve

    The curve parameter nearest a given point.

    STEP curves and surfaces: parameters from points step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Parameters of a point on a B-spline surface

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

    [S_u·S_u S_u·S_v; S_u·S_v S_v·S_v] d = −[r·S_u; r·S_v], r = S(u, v) − q

    STEP curves and surfaces: parameters from points step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Surface of linear extrusion

    The point of a curve swept along a vector, and the (u, v) of a point.

    S(u, v) = C(u) + v · vec; v = (q − C(u))·d ÷ |vec|, u = project(q − v · vec)

    STEP curves and surfaces: parameters from points step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Offset surface

    The point of a surface moved a distance along its normal.

    S_off(u, v) = S(u, v) + d · n, n = (ΔS_u × ΔS_v) ÷ |…|

    STEP curves and surfaces: parameters from points step/geom.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Length and angle units

    The file's length unit in millimeters and its plane-angle unit in radians.

    mm = prefix × 1000 for a meter; a conversion-based unit = its value × its base unit

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Point coordinates

    A CARTESIAN_POINT in millimeters.

    (x, y, z) × unit in mm

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Radii and cone angles

    The radius of a cylinder, cone, sphere or torus in millimeters and a cone's half angle in radians.

    r × unit in mm; α × angle unit, accepted when 0 < |α| < π ÷ 2

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Knot vectors

    The full knot vector of a B-spline from the file's knots and multiplicities, or the one a uniform, quasi-uniform or Bézier form implies.

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    Exact
  • Model size and chord tolerance

    The size of the model and the distance a triangle may stray from a curved face.

    size = diagonal of the box around every point; tol = max(4e-4 × size, 1e-4 mm)

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Closing a loop of edges

    Drops the last point of an edge loop when it repeats the first.

    |first − last| ≤ 0.01 × tol

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Placement matrices

    A placement as a 4 × 4 matrix, the product of two and the inverse of one.

    M⁻¹ = [Rᵀ, −Rᵀ t]

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • A component placed in its assembly

    The transform that carries a component's coordinates into the assembly that uses it.

    T = M(A₂) × M(A₁)⁻¹

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Placed vertex positions

    Every vertex of a solid moved to its place and stored for the app.

    p′ = R p + t

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Faceted faces

    Triangles for a flat face given as loops of points.

    n = Σ ((yᵢ − yⱼ)(zᵢ + zⱼ), (zᵢ − zⱼ)(xᵢ + xⱼ), (xᵢ − xⱼ)(yᵢ + yⱼ))

    STEP import: units, points and assembly placement step/read.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Points along an edge

    The points of an edge from its start vertex to its end vertex along its curve.

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • How finely a curve is divided

    The parameters at which an edge curve is sampled.

    circle step = min(π ÷ 24, 2 acos(1 − tol ÷ r)); else halve while the middle is more than tol from the chord or the turn exceeds π ÷ 24

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Turn and crossing tests

    Whether three points turn left, right or run straight, and whether two segments cross.

    x = (a − o) × (b − o); left when x > 1e-9 × |ab| × |bc|, right when x < −1e-9 × |ab| × |bc|

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Holes joined to the outer ring

    One ring made from a face's outer loop and its holes by bridges, ready for ear clipping.

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Ear clipping

    Triangles of a simple polygon in the plane.

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • A loop in the surface's (u, v)

    The parameters of each boundary point, with periodic directions unwrapped and poles split.

    uᵢ ← uᵢ + round((uⱼ − uᵢ) ÷ period) × period

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Scaled layout and first triangles

    The (u, v) points scaled to lengths, the loops given their turning sense, and the first triangulation.

    M = (u × s_u, v × s_v); loop sense = sign of Σ (xᵢ yⱼ − xⱼ yᵢ)

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Apex of a cone

    The parameter at which a cone's radius reaches zero, for a face that closes at the apex.

    R = |S(0, 0) − S(π, 0)| ÷ 2; k = |S(0, 1) − S(π, 1)| ÷ 2 − R; v_apex = −R ÷ k

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Interior grid spacing

    How far apart interior points are placed on each kind of surface.

    angle step = min(π ÷ 24, 2 acos(1 − tol ÷ r))

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Interior points inserted

    Grid points added inside a face and joined into the triangulation.

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • In-circle test

    Whether a fourth point lies inside the circle through three others.

    det of rows (a − d, |a − d|²), (b − d, |b − d|²), (c − d, |c − d|²)

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Edge flips

    Inside edges flipped toward a Delaunay triangulation in the scaled (u, v).

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Refinement to the chord tolerance

    Inside edges split where the surface is farther than the tolerance from the triangles.

    split when |S(mid uv) − (P_a + P_b) ÷ 2| > tol, or when a triangle's center is more than tol from its plane

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Facing and self-check

    The 3D position of every point, the triangles turned to face outward, and a check of how far the mesh is from the surface.

    worst = max |S(center uv) − center of triangle| over up to 64 triangles; noted when worst > 25 × tol

    STEP import: triangles for curved faces step/tess.js
    • BimCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Unit factors

    What a number with a unit is multiplied by to give millimeters or degrees.

    mm 1; cm 10; m 1000; in 25.4; ft 304.8; deg 1; rad 180 ÷ π

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • A number with a unit

    Reads a number and converts it by the unit written right after it.

    v = Number(text) × factor

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Sine, cosine and tangent in degrees

    sin, cos and tan of an angle given in degrees.

    sin(x) = clean(Math.sin(x × π ÷ 180)); tan refused when |cos| < 1e-12

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Trig result rounded to 15 digits

    Rounds a sine, cosine or tangent to 15 significant digits and turns a value below 1e-15 into 0.

    |x| < 1e-15 → 0; otherwise Number(x.toPrecision(15))

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Inverse trigonometry and square root

    asin, acos, atan, atan2 in degrees, and sqrt.

    asin(x) = Math.asin(clamp(x, −1, 1)) ÷ (π ÷ 180); sqrt(x) = √max(0, x)

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Power, exponential and logarithms

    pow, exp, ln and log.

    pow(a, b) = aᵇ; ln and log need x > 0

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • ceil, floor and int

    Rounds up, down or toward zero to a whole number.

    ceil(x) = ⌈x − ε⌉; floor(x) = ⌊x + ε⌋; int(x) = trunc(x + sign(x) × ε); ε = 1e-9 × max(1, |x|)

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • round(x, digits)

    Rounds to a number of decimal places from 0 to 10, halves away from zero.

    y = |x| × 10ᵈ; r = ⌊y + 0.5 + 1e-9 × max(1, y)⌋; result = ± r ÷ 10ᵈ

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Comparisons

    The six comparison operators, giving 1 or 0.

    tol = 1e-9 × max(1, |a|, |b|); a == b when |a − b| ≤ tol; a < b when a < b − tol

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Arithmetic operators

    Addition, subtraction, multiplication, division, remainder and power.

    a % b = a − b × ⌊a ÷ b⌋; division and remainder refuse b = 0

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Number as text

    The text a number is written as when it is put back into an expression or a message.

    Number(v.toPrecision(12)) as text

    Parameter expressions expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Solve for a parameter

    The value of the named parameter for which the expression equals the target.

    secant: c = b − f(b) × (b − a) ÷ (f(b) − f(a)); accept when |f| ≤ 1e-9 × max(1, |target|, |x₀|)

    Solving an expression for one parameter expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Rounding of the answer

    Replaces the answer by its 13-digit rounding when the two are practically equal.

    r = x to 13 significant digits; use r when |r − x| ≤ 1e-12 × max(1, |x|)

    Solving an expression for one parameter expr.js
    • CadCraft
    • BimCraft
    • PartCraft
    64-bit
  • Unit sizes

    Builds each unit's row: its fraction of the base unit and the factor used for quick conversion.

    factor = n ÷ d (× π for degrees and gons)

    Unit table: reading and writing values unit-table.js Every app
    Exact
  • Numbers and fractions

    Reads 6, 6.5, 6 1/2, 6-1/2 or 1/2 as a number.

    whole + numerator ÷ denominator

    Unit table: reading and writing values unit-table.js Every app
    64-bit
  • Feet and inches

    Reads 12'6", 12'-6 1/2" or 6" as inches.

    inches = feet × 12 + inches

    Unit table: reading and writing values unit-table.js Every app
    64-bit
  • Degrees, minutes and seconds

    Reads 45°30'15" or 45d30m15s as degrees.

    degrees + minutes ÷ 60 + seconds ÷ 3600

    Unit table: reading and writing values unit-table.js Every app
    64-bit
  • Slopes

    Reads 2%, 3H:1V, 1:3 or 6/12 as a grade (rise over run).

    percent ÷ 100; H:V → V ÷ H; rise:run → rise ÷ run

    Unit table: reading and writing values unit-table.js Every app
    64-bit
  • Writing feet and inches

    Writes a length as feet, inches and a fraction of an inch.

    n = round(|inches| × den); feet = ⌊n ÷ 12den⌋; inches = ⌊rest ÷ den⌋; fraction = rest ÷ den, reduced

    Unit table: reading and writing values unit-table.js Every app
    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.