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

  • Line

    Writes a line's two end points.

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Polyline vertices

    Writes the vertices of a lightweight polyline.

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Vertex widths

    Writes the start and end width at a polyline vertex.

    equal widths: one value, −|width|

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Linetype pattern length

    The total length of a linetype's dash pattern.

    length = Σ |element length|

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Text direction

    The x-axis direction written for a block of text.

    x axis = (cos θ, sin θ, 0)

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Block scale

    Writes the three scale factors of a block reference in the format's compact form.

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Single-line text

    Writes a text's insertion point, height, rotation, width factor and oblique angle.

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Extension record values

    Writes the numbers kept in an extension record.

    DWG object values written and read dwg/objects-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Block content matrix of a multileader

    The 4 × 4 matrix written for a multileader's block content when the model gives none.

    M = translate(l) · rotate_z(θ) · scale(s)

    DWG object values written and read dwg/mleader-write.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Line read

    Reads a line's two end points.

    DWG object values written and read dwg/objects-read.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Polyline vertices read

    Reads the vertices of a lightweight polyline.

    DWG object values written and read dwg/objects-read.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • North direction of older geolocation data

    Turns the north angle of a version 1 geolocation object into a direction vector.

    north = (sin a, cos a)

    DWG object values written and read dwg/objects-read.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • TakeoffCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Lineweight to the file's lineweight index

    Picks the stored lineweight that is nearest to the one the layer or object has.

    index = the i with the smallest |table[i] − lineweight|

    Values changed when a DWG is written dwg/write.js
    • CadCraft
    • ModelCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    Exact
  • Ellipse with a ratio above 1

    Rewrites an ellipse whose minor axis is longer than its major axis so the file holds a ratio of 1 or less.

    major′ = (−m_y, m_x) × ratio; ratio′ = 1 ÷ ratio; start and end − π ÷ 2

    Values changed when a DWG is written dwg/write.js
    • CadCraft
    • ModelCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Ray and construction line direction

    Writes the direction of a ray or construction line as a unit vector.

    d′ = d ÷ |d|

    Values changed when a DWG is written dwg/write.js
    • CadCraft
    • ModelCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Drawing extents

    The lower left and upper right corner of model space written to the file header.

    min and max of x, y, z over the defining points

    Values changed when a DWG is written dwg/write.js
    • CadCraft
    • ModelCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Default angles of a light

    The hotspot and falloff angles written for a light that has none of its own.

    hotspot = π ÷ 4; falloff = π ÷ 4 + 0.0872664626

    Values changed when a DWG is written dwg/solid-write.js
    • CadCraft
    • ModelCraft
    • CivilCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Arcs into chords

    Replaces each bulge arc of a path by straight chords that stay within a tolerance of the arc.

    θ = 4 atan(b); r = chord ÷ (2 sin(|θ| ÷ 2)); steps = ⌈|θ| ÷ (2 acos(1 − min(tol, r) ÷ r))⌉

    Laser job paths, fill lines and run estimate laser/laser-geom.js
    • CadCraft
    • PartCraft
    64-bit
  • Signed area of a loop

    The area of a closed path, used to tell which loop is the larger when one lies in another.

    A = ½ Σ (xᵢ yᵢ₊₁ − xᵢ₊₁ yᵢ)

    Laser job paths, fill lines and run estimate laser/laser-geom.js
    • CadCraft
    • PartCraft
    64-bit
  • Length of a path

    The total length of a flattened path.

    L = Σ √(Δx² + Δy²)

    Laser job paths, fill lines and run estimate laser/laser-geom.js
    • CadCraft
    • PartCraft
    64-bit
  • Which loop lies in which

    Counts how many other loops contain each loop, so inner shapes are cut first.

    two edge midpoints inside the other loop, and the other loop larger in area

    Laser job paths, fill lines and run estimate laser/laser-geom.js
    • CadCraft
    • PartCraft
    64-bit
  • Turn into and out of the fill direction

    Rotates a point by the fill angle so the fill lines are horizontal, and back.

    x′ = x cos a − y sin a; y′ = x sin a + y cos a; a in degrees × π ÷ 180

    Laser job paths, fill lines and run estimate laser/laser-geom.js
    • CadCraft
    • PartCraft
    64-bit
  • Fill lines of a closed shape

    The scan lines that fill the even–odd region of the loops, with the spans to burn on each line.

    y_k = (k + 0.5) × interval + offset; x = a_x + (b_x − a_x)(y − a_y) ÷ (b_y − a_y)

    Laser job paths, fill lines and run estimate laser/laser-geom.js
    • CadCraft
    • PartCraft
    64-bit
  • Machine coordinates

    Moves every point so the job's lower left corner is the machine's 0, 0.

    x_machine = x − x_origin; y_machine = y − y_origin

    Laser job paths, fill lines and run estimate laser/laser-plan.js
    • CadCraft
    • PartCraft
    64-bit
  • Burn length, travel and time

    The length burned, the length traveled with the laser off, and the time of the job.

    burn = Σ d × passes; time = Σ (d ÷ speed) × 60 × passes

    Laser job paths, fill lines and run estimate laser/laser-plan.js
    • CadCraft
    • PartCraft
    64-bit
  • Fill lines into moves

    Turns the fill lines back to drawing coordinates and adds the overscan before and after each line.

    start = first − dir × overscan; end = last + dir × overscan

    Laser job paths, fill lines and run estimate laser/laser-plan.js
    • CadCraft
    • PartCraft
    64-bit
  • Picture rows into moves

    Lays a picture's burn levels on its rectangle as rows of moves with a power for each run.

    cols = round(w ÷ interval); dx = w ÷ cols; y = y₀ + h − (r + 0.5) dy; power = min + (max − min) × level ÷ 255

    Laser job paths, fill lines and run estimate laser/laser-plan.js
    • CadCraft
    • PartCraft
    64-bit
  • Gray value of each engraving cell

    The average gray of the picture's pixels under each cell of the engraving grid.

    gray = Σ w × pixel ÷ Σ w, w = overlap area of pixel and cell

    Burn levels of an engraved picture laser/laser-image.js
    • CadCraft
    • PartCraft
    32-bit in part
  • Burn level of each cell

    Turns the gray values into burn levels from 0 to 255 by the chosen method.

    darkness = 1 − (gray ÷ 255)^gamma; threshold: darkness > t; gray steps: round(round(darkness × (n − 1)) ÷ (n − 1) × 255)

    Burn levels of an engraved picture laser/laser-image.js
    • CadCraft
    • PartCraft
    32-bit in part
  • Arc of a glyph

    The points of the round parts of letters.

    n = max(2, ⌈|a₁ − a₀| ÷ 15⌉); p = (c_x + r_x cos a, c_y + r_y sin a)

    Text from drawings as stroked edges m3d/strokefont.js
    • CadCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Width of a string

    The advance of a string in drawing units, used to align and wrap text.

    width = (Σ (glyph width + 2) − 2) × h ÷ 9 × width factor

    Text from drawings as stroked edges m3d/strokefont.js
    • CadCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Strokes of a string

    The polylines of a string at a given height, width factor and slant.

    x = x₀ + p_x × s_x + p_y × s × tan(oblique); y = p_y × s; s = h ÷ 9

    Text from drawings as stroked edges m3d/strokefont.js
    • CadCraft
    • ModelCraft
    • PartCraft
    64-bit
  • Line fit

    The best straight line through a run of center-line pixels, and how far the worst pixel lies from it.

    θ = ½ × atan2(2·Sxy, Sxx − Syy); ends = feet of the first and last points on the line through the centroid

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Circle fit

    The best circle through a run of center-line pixels, its sweep and the angles of an arc.

    Kåsa: solve the 2 × 2 system for the center about the centroid, r = √(uc² + vc² + (Suu + Svv) ÷ n); then Gauss-Newton on d − r

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Corner detection

    Where a chain of pixels turns sharply, so it can be cut there before fitting.

    turn = |atan2(r − q) − atan2(q − p)| over ± w steps; corner when turn ≥ 0.6 rad and largest nearby

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Splitting a chain into lines and arcs

    Fits a line, else an arc, else splits the chain at the point farthest from its chord, and joins neighbors that fit as one.

    distance to chord = |(P − A) × (B − A)| ÷ |B − A|

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Joining collinear lines

    Merges two lines that lie on the same straight line and nearly touch.

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Squaring level and plumb lines

    Makes nearly horizontal and vertical lines exactly so, and gives lines of one wall the same coordinate.

    y = (y₁ + y₂) ÷ 2; shared coordinate = Σ(coordinate × length) ÷ Σ length

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Closing corners

    Moves a line end to the point where its line meets a nearby line.

    s = ((B₁ − E) × v) ÷ (u × v); new end = E + s·u

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Lines and arcs in image coordinates

    The traced lines and arcs with the window offset added and the arc end points worked out.

    start = (cx + r·cos a₀, cy + r·sin a₀); end = (cx + r·cos a₁, cy + r·sin a₁)

    Tracing a scan into lines and arcs raster/trace.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Crossing of two traced lines

    The point where two traced line segments cross.

    d = (a₂ − a₁) × (b₂ − b₁); t = ((b₁ − a₁) × (b₂ − b₁)) ÷ d; point = a₁ + t·(a₂ − a₁)

    Tracing a scan into lines and arcs raster/snap.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Snap points of a trace

    The ends, middles, arc centers, corners and crossings offered for snapping.

    middle = (p₁ + p₂) ÷ 2; arc middle at angle (a₀ + a₁) ÷ 2; corner = mean of the ends within 3 px

    Tracing a scan into lines and arcs raster/snap.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Black-and-white level (Otsu)

    The grey level that best separates ink from paper for the whole sheet.

    maximize w_B × w_F × (m_B − m_F)² over the 256 levels

    Scan clean-up and JPEG decoding raster/image.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Local threshold (Sauvola)

    Decides ink or paper for each pixel from the mean and spread of the pixels around it.

    ink when v ≤ mean × (1 + k × (sd ÷ 128 − 1)); sd = √(Σv² ÷ n − mean²)

    Scan clean-up and JPEG decoding raster/image.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Sheet skew angle

    The angle by which the long lines of a scanned sheet are rotated.

    score(angle) = Σ rows² + Σ columns² of the ink projected at that angle; best angle on a 0.25° then 0.02° grid

    Scan clean-up and JPEG decoding raster/image.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Rotating the image

    Turns a grey image by an angle about its middle.

    source = c + R(angle) × (pixel − c); value = bilinear mix of the 4 nearest source pixels

    Scan clean-up and JPEG decoding raster/image.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • JPEG inverse cosine transform

    Turns the stored frequency coefficients of an 8 × 8 block back into pixel values.

    pixel = round(Σ_u Σ_v C(x,u)·C(y,v)·coef(u,v) + 128), clamped to 0–255

    Scan clean-up and JPEG decoding raster/jpeg.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • JPEG color conversion

    Converts the decoded luminance and color-difference values to red, green and blue.

    R = Y + 1.402·Cr; G = Y − 0.344136·Cb − 0.714136·Cr; B = Y + 1.772·Cb

    Scan clean-up and JPEG decoding raster/jpeg.js
    • CadCraft
    • BimCraft
    • ModelCraft
    • CivilCraft
    • PartCraft
    64-bit
  • Table values in millimeters

    Converts each published row to millimeters, mm² and kg/m.

    mm = in × 25.4; mm² = in² × 25.4 × 25.4; kg/m = lb/ft × 1.48816394; r = (k_des − t_f) × 25.4

    Steel section dimensions, areas and outlines shapes/sections.js
    • CadCraft
    • BimCraft
    • DetailCraft
    • PartCraft
    64-bit
  • Exact section area

    The cross-section area worked out from the dimensions, with fillets and rounded corners included.

    I: 2·b_f·t_f + (d − 2t_f)·t_w + (4 − π)·r²; RHS: 2t(h + b − 2t) − (4 − π)(r_o² − r_i²); CHS: π(D − t)·t

    Steel section dimensions, areas and outlines shapes/sections.js
    • CadCraft
    • BimCraft
    • DetailCraft
    • 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.