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

  • Construction line direction

    The unit direction of an infinite line or ray.

    direction = (dx, dy) ÷ √(dx² + dy²)

    DXF reading: objects from the file's text dxf.js
    • CadCraft
    64-bit
  • Extra sheet read back from a block

    Rebuilds a sheet and its viewports from the block an R12 file keeps them in.

    viewport center = ((x_min + x_max) ÷ 2, (y_min + y_max) ÷ 2); w = x_max − x_min; h = y_max − y_min

    DXF reading: objects from the file's text dxf.js
    • CadCraft
    64-bit
  • A group value by its code

    Turns one group's text into a real number, a whole number, a true or false, or text.

    codes 10–59, 110–149, 210–239, 460–469, 1010–1059: parseFloat; 60–99, 160–179, 270–289, 370–389, 400–409, 420–429, 440–459, 1060–1071: parseInt

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Arc angles

    An arc's start and end angles in radians.

    angle = degrees × (π ÷ 180)

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Multi-line text direction

    The direction vector of multi-line text, from the file's vector or from its rotation angle.

    x axis = group 11 when present; otherwise (cos(a), sin(a)), a = degrees × (π ÷ 180)

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Hatch arc and ellipse edges

    The center, radius or axes, and start and end angles of the curved edges of a hatch boundary.

    angle = degrees × (π ÷ 180); missing end angle = 360 degrees

    DXF reading into the shared drawing model dxf-model.js
    • CadCraft
    • BimCraft
    • TakeoffCraft
    • CivilCraft
    64-bit
  • Number text (R12)

    The text every real number is written as in an R12 file.

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

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

    Writes a 2D point as three groups.

    x → f(x); y → f(y); z → 0.0

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

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

    degrees = (a mod 2π) × 180 ÷ π

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

    The defining points, text point and angles written for a dimension.

    linear: point 10 = end of the dimension line on the second extension line; radial: near = c + r × (cos a, sin a), far = c − r × (cos a, sin a); angles in degrees

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

    A sheet viewport's twist, view height and view center.

    view height = h ÷ s

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Ellipses and splines as polylines (R12)

    Writes an ellipse or a spline as a polyline along the curve, because R12 has neither object.

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • Hatches as solids or outlines (R12)

    Writes a filled triangle or quadrilateral as a SOLID and any other hatch as closed polylines of its rings.

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

    A text's position, height, rotation, width factor and oblique angle.

    rotation° = rot × 180 ÷ π; oblique° = obl × 180 ÷ π

    DXF writing: numbers as text dxf.js
    • CadCraft
    64-bit
  • 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

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.