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

  • Point in absolute coordinates

    One scan point, from Cartesian or spherical fields, moved by the scan's pose.

    spherical: x = r cos e cos a, y = r cos e sin a, z = r sin e; then p′ = R × p + T

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Rotation matrix from the pose quaternion

    The 3 × 3 rotation of a scan from its quaternion (w, x, y, z).

    q ÷ |q|; R = [1 − 2(y² + z²), 2(xy − zw), 2(xz + yw); 2(xy + zw), 1 − 2(x² + z²), 2(yz − xw); 2(xz − yw), 2(yz + xw), 1 − 2(x² + y²)]

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Field values of a packet

    Decodes one field of a data packet into numbers: 64-bit floats, 32-bit floats or scaled integers.

    float: as stored; integer: (raw + minimum) × scale + offset

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Bit-packed integer

    Reads an unsigned integer of up to 64 bits from a bit position in a packet.

    value = Σ chunkᵢ × 2^(32 i), chunks of up to 32 bits

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Bits from the stream

    Extracts up to 32 bits starting at any bit of a byte buffer, least significant bit first.

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Field description from the XML

    How many bits an integer field uses, and its minimum, scale and offset.

    bits = smallest b with 2ᵇ > maximum − minimum (at most 64)

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Thinning to the point budget

    How many points are kept and at what rate when a file has more points than the budget.

    cap = max(1, min(listed, ⌊budget⌋)); rate = min(1, cap ÷ listed); keep a point each time the running sum of rate reaches 1

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    64-bit
  • Points from the library's text

    Parses the x y z lines the web-e57 library returns and keeps the bounds and the thinned points.

    x, y, z = Number of each field of a line

    E57 point cloud reading e57.js
    • CadCraft
    • BimCraft
    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
  • Rounding of stored values

    The two rounding helpers every stored number of an item goes through.

    r4(v) = round(v × 10000) ÷ 10000; r2(v) = round(v × 100) ÷ 100

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Block to millimeters

    The transform from a block's own coordinates and units to the item's millimeters.

    M = [mm, 0, 0, mm, −base.x·mm, −base.y·mm]; scale of a transform = √|det|; angle = r4(atan2(y, x) in degrees)

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Lines, circles and arcs of a block

    A block's lines, circles and arcs as plan entities in millimeters.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Nested block references

    The transform of a block reference inside the block, with its rows and columns.

    local = T(insert) · R(rotation) · S(sx, sy) · T(−base + column·spacing ÷ sx, row·spacing ÷ sy)

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Mesh body from a block's 3D faces

    The item's 3D body and height when the block holds 3D faces.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Arcs as points, 5° steps

    The points that replace a circle or arc that cannot stay an arc.

    n = max(8, ⌈sweep ÷ 5°⌉); point = c + r·(cos a, sin a)

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Splines as points

    The points that replace a block's spline in the item's plan.

    de Boor recurrence at u = lo + (hi − lo)·s ÷ n, n = max(16, 8 × control points)

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Arc points for bounds

    The points of an arc used to find a plan's bounds.

    n = max(4, ⌈sweep ÷ 10°⌉); point = c + r·(cos a, sin a)

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Bounds of a plan

    The box round an item's plan, from which its width and depth are taken.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Box body on a plan

    A box body standing on the plan's bounds with a given height.

    w = max x − min x; d = max y − min y; each of x, y, z, w, d, h rounded to 4 decimals

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Item from a mesh file

    A mesh file's triangles as an item body in millimeters, with its footprint and sizes.

    p = file point × unit in mm; Y-up: (x, y, z) → (x, −z, y); stored = r4(p − (center x, max y, min z))

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • STL corners

    The corner points of an STL file's triangles.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • glTF accessor values

    The numbers of a glTF position or index accessor.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • glTF node transforms

    The matrix that places each glTF node's mesh.

    M = T · R(q) · S, R from the quaternion (qx, qy, qz, qw)

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Convex hull footprint

    The outline round a mesh item's points, used as its plan.

    monotone chain; turn = (a − o) × (b − o), popped when ≤ 0

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Box of a body

    The box a body fills: a box body itself, or the extent of a mesh body.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Box item from width, depth and height

    The rectangle plan and box body of an item given only by its sizes.

    x from −w ÷ 2 to +w ÷ 2; y from −d to 0; label height = min(0.18 d, 150), reduced to fit 90% of w

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Sizes from attributes

    Width, depth and height read from a block's attributes.

    Library item geometry from blocks, meshes and tables libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Millimeters per unit

    The table of unit factors.

    in 25.4; ft 304.8; yd 914.4; mi 1 609 344; mil 0.0254; µm 0.001

    Lengths and units for Library items libitem.js
    • CadCraft
    • BimCraft
    Exact
  • Length from text

    A typed or stored length in millimeters.

    with a unit: n × factor; feet and inches: (feet × 12 + inches + a ÷ b) × 25.4; bare number: n × mm per unit

    Lengths and units for Library items libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Drawing units

    The millimeters per drawing unit of a DWG or DXF file.

    Lengths and units for Library items libitem.js
    • CadCraft
    • BimCraft
    Exact
  • Pipe size in eighths of an inch

    A decimal inch size written as a fraction, such as 1 1/2".

    eighths = round((n − ⌊n⌋) × 8)

    Lengths and units for Library items libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Size label on the preview

    The overall width and depth printed on an item's preview picture.

    millimeters: round(mm); inches: round(mm ÷ 25.4 × 8) eighths

    Lengths and units for Library items libitem.js
    • CadCraft
    • BimCraft
    64-bit
  • Warp plan for a picture or tile

    How finely a map image is cut into patches so that it lands in the right place on screen.

    tolerance = 0.25 ÷ zoom project units, rounded to a half power of 2

    Map layers under the drawing maplayers.js
    • CadCraft
    • BimCraft
    32-bit, display only
  • Drawing the patches

    Each patch of a map image drawn on the canvas.

    Map layers under the drawing maplayers.js
    • CadCraft
    • BimCraft
    32-bit, display only
  • Local placement record

    The scale, rotation and point pair that tie drawing coordinates to grid coordinates.

    scale = m per drawing unit ÷ m per grid unit; from = (x, y); to = (e, n)

    Drawing placed on a map grid maplayers.js
    • CadCraft
    • BimCraft
    64-bit
  • Page box and rotation matrix

    The matrix from PDF user space to the page as displayed: origin at the lower-left corner, y up, the page's rotation applied.

    0°: [1 0 0 1 −x₀ −y₀]; 90°: [0 −1 1 0 −y₀ W + x₀]; 180°: [−1 0 0 −1 W + x₀ H + y₀]; 270°: [0 1 −1 0 H + y₀ −x₀]

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    64-bit
  • Matrix product

    Combines the current matrix with one the page's content applies.

    [a b c d e f] = m · k for 2 × 3 affine matrices

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    64-bit
  • Path points

    Each move, line and curve point of a path, taken through the current matrix into displayed-page points.

    x′ = a·x + c·y + e; y′ = b·x + d·y + f; quadratic to cubic: c₁ = p + ⅔(q − p), c₂ = x + ⅔(q − x)

    PDF page vectors and snapping to them pdf-vector.js
    • CadCraft
    • BimCraft
    32-bit in part

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.