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

  • Multi-line text as single lines (R12)

    The position of each line of a multi-line text, written as separate single-line texts.

    p = T(x, y) × R(rot) × (anchor x of the text box, baseline of line k)

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Construction lines as segments (R12)

    Writes an infinite line or ray as a line across the drawing's extents.

    a = p + d × t₀; b = p + d × t₁

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Extents of what was written (R12)

    The smallest and largest x and y of the model-space objects written.

    min and max over the written points

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Linetype pattern (R12)

    A linetype's total pattern length and its dashes and gaps.

    length = Σ |elementᵢ|

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Center mark size (R12)

    The center mark size written with each dimension style.

    DIMCEN = arrow size ÷ 2 (2.5 when no arrow size is set)

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Number text (2000)

    The text every real number is written as in a DXF 2000 file.

    not finite → 0.0; |n| < 1e-12 → 0.0; otherwise n rounded to 15 significant digits

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Radians to degrees (2000)

    Converts an angle to the degrees DXF stores.

    degrees = (r × 180) ÷ π

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Point (2000)

    Writes a point as three groups.

    x → f(x); y → f(y); z → f(z); a missing coordinate → 0.0

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Arc (2000)

    An arc's center, radius and its angles in degrees.

    start° = (a₀ × 180) ÷ π; end° = (a₁ × 180) ÷ π

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Ellipse (2000)

    An ellipse's center, major axis, axis ratio and start and end parameters, with the ratio brought to 1 or less.

    ratio > 1: major′ = (−m_y × ratio, m_x × ratio); ratio′ = 1 ÷ ratio; parameters − π ÷ 2

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Hatch pattern lines (2000)

    A pattern hatch's angle, scale and each pattern line's angle, base, offset and dashes.

    angles° = (radians × 180) ÷ π

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Spline (2000)

    A spline's degree, knots, weights, control points and fit points.

    knot, control point and fit point tolerances written as 1E-10

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Extended data values (2000)

    Writes the extra values attached to an object: text, reals and whole numbers.

    code 1040: f(value); code 1070: value | 0

    DXF writing: numbers as text dxf2000.js
    • CadCraft
    64-bit
  • Pointer with the locked fields applied

    The point shown and used while fields are locked: a typed distance or angle from the base point, or a typed X or Y.

    polar: p = base + d × (cos a, sin a), a = typed degrees × π ÷ 180 or atan2 of the pointer; xy: (typed X or pointer x, typed Y or pointer y)

    Dynamic input: points from typed distance, angle, X and Y dynin.js
    • CadCraft
    64-bit
  • Field values while the pointer moves

    The distance and angle from the base point, or X and Y, that the fields show.

    d = √(Δx² + Δy²); a = atan2(Δy, Δx) × 180 ÷ π, brought into 0 to 360

    Dynamic input: points from typed distance, angle, X and Y dynin.js
    • CadCraft
    64-bit
  • Text sent on Enter

    The coordinate text the command line receives: a relative distance and angle, or an absolute X and Y.

    @d<a from the last point; otherwise #x,y with x = base_x + d × cos a, y = base_y + d × sin a

    Dynamic input: points from typed distance, angle, X and Y dynin.js
    • CadCraft
    64-bit
  • Number text for the command line

    Writes a value taken from the pointer as text.

    text = value rounded to 10 decimals, trailing zeros dropped

    Dynamic input: points from typed distance, angle, X and Y dynin.js
    • CadCraft
    64-bit
  • 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
  • View frames

    The right, up and toward-the-viewer directions of the seven standard views.

    iso: u = (1, 1, 0) ÷ √2; v = (−1, 1, 2) ÷ √6; w = (1, −1, 1) ÷ √3

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Edges and triangles in the view's frame

    Every vertex of the model as (right, up, depth) in the view, and which soft edges are outlines from this side.

    q = (p · u, p · v, p · w); soft edge kept when its two faces face opposite ways

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Working tolerance

    The tolerance every later step uses, from the size of the projected model.

    diag = √(Δu² + Δv²); tol = diag × 1e-6

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Is a point hidden

    Says whether a point of an edge lies behind some triangle of the model.

    l₁, l₂ from signed areas ÷ triangle area; l₃ = 1 − l₁ − l₂; hidden when all ≥ 1e-9 and l₁ z_a + l₂ z_b + l₃ z_c > depth + tol

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Visible and hidden runs of an edge

    Splits an edge into stretches that are visible and stretches that are hidden.

    n = clamp(⌈L ÷ (diag ÷ 300)⌉, 1, 400) samples; each change bisected until (hi − lo) × L ≤ tol

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Merging pieces on one line

    Groups segments that lie on the same line and joins their overlapping spans.

    key = round(atan2(dy, dx) × 1e6) and round(offset ÷ (20 × tol)); spans joined when the gap ≤ tol

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Merged lines back to segments

    Writes each merged span as a segment, and removes from hidden lines what a visible line covers.

    point = offset × (−dy, dx) + t × (dx, dy)

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Scale from text

    Reads a scale typed as 1:50, 2:1, 1/20 or 0.5.

    a:b → a ÷ b; accepted when 0 < scale < 1e6

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • Paper units per meter and automatic scale

    How many drawing or paper units one meter of the model is, and the largest standard scale that fits the sheet.

    inch sheet: 1 ÷ 0.0254; mm sheet: 1000; model: 1 ÷ meters per unit; fit: size × units per meter × scale ≤ 0.45 × paper size

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • View lines in drawing units

    The 2D lines of the view, centered on the block's base point and scaled.

    x = (u − u_center) × f; y = (v − v_center) × f; f = units per meter × scale

    Flat views of 3D solids flatview.js
    • CadCraft
    64-bit
  • What a dimensional constraint measures

    The current horizontal, vertical or direct distance, radius, diameter or angle of the constrained geometry.

    hdist = s × (x₁ − x₀); dist = |p₁ − p₀| or s × signed distance from the line; diameter = 2r; angle = s × atan2(u × v, u · v) × 180 ÷ π; arc angle = (a₁ − a₀) mod 2π in degrees

    Constraint values and signs gcons.js
    • CadCraft
    64-bit
  • Signed distance from a line

    How far a point or a circle's center lies from an infinite line, positive on the left of its direction.

    d = (u_x × (p_y − l_y) − u_y × (p_x − l_x)) ÷ |u|

    Constraint values and signs gcons.js
    • CadCraft
    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.