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

  • Route network

    Builds the network of cable routes: nodes, and edges with their lengths, split where one route's end lands on another.

    split point = a + (b − a) × u; edge length = √(Δx² + Δy²)

    Installation loads and cable lengths addons/electrical/lib/install.js
    • CadCraft
    64-bit
  • Device joined to the nearest route

    Connects a board or device to the nearest point of a route within reach, and counts the drop.

    drop = √d²; split lengths = len × u and len × (1 − u)

    Installation loads and cable lengths addons/electrical/lib/install.js
    • CadCraft
    64-bit
  • Shortest routes from the board

    The shortest distance from the board to every node of the route network.

    Dijkstra: dist[v] = min(dist[v], dist[u] + len)

    Installation loads and cable lengths addons/electrical/lib/install.js
    • CadCraft
    64-bit
  • Cable length of a circuit

    The meters of cable a circuit needs.

    meters = Σ used edges × meters per unit + devices reached × 0.5 + 1

    Installation loads and cable lengths addons/electrical/lib/install.js
    • CadCraft
    64-bit
  • Cross-section of the cables

    The total cross-sectional area of a set of cables.

    area = Σ (π ÷ 4) × od² × n

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Conduit fill

    The percentage of a conduit's inside area the cables take, and whether it is within the limit.

    pct = 100 × used ÷ (π ÷ 4 × id²); free = area × limit ÷ 100 − used

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Smallest conduit that holds the cables

    The first trade size, going up, whose fill is within the limit.

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Cable tray fill

    The fill of a tray by area, or by the sum of cable diameters when the cables lie in one layer.

    area mode: pct = 100 × used ÷ (width × depth); layer mode: pct = 100 × Σ (od × n) ÷ width

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Shortest way through the carriers

    The shortest path between two nodes of the tray and conduit network, and its length.

    Dijkstra: d = dist[u] + segment length × 1000

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Cable length through each run

    For each cable, the runs it passes through and its length in each.

    length in a run = Σ segment length × 1000 over that run's segments on the path

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Cable schedule length

    The length of each cable in the schedule, with slack and an allowance at each end.

    length m = (route mm × (1 + slack) + 2 × ends mm) ÷ 1000, rounded to 0.1

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Cable list read from CSV

    Reads cable tags, outside diameters and counts from a CSV file.

    Conduit and tray fill, cable schedule addons/electrical/lib/mep/carrier.js
    • CadCraft
    • BimCraft
    64-bit
  • Squared distance from a point to a segment

    How far a point is from a wire segment, and where along the segment the nearest point lies.

    u = clamp((p − a)·(b − a) ÷ |b − a|², 0, 1); q = a + u (b − a); d² = |p − q|²

    Schematic wires, pins and connections addons/electrical/lib/wires.js
    • CadCraft
    64-bit
  • Points within a radius

    Finds the stored points within a distance of a point.

    match when (Δx² + Δy²) ≤ r²

    Schematic wires, pins and connections addons/electrical/lib/wires.js
    • CadCraft
    64-bit
  • What a wire end connects to

    Joins a wire end to other wire ends, to pins and to the middle of other wires that it touches.

    connected when distance² ≤ tol², tol = 0.05

    Schematic wires, pins and connections addons/electrical/lib/wires.js
    • CadCraft
    64-bit
  • Where a wire number goes

    The middle and direction of the longest segment of a net, for its wire number.

    x = (aₓ + bₓ) ÷ 2; y = (a_y + b_y) ÷ 2; rot = atan2(Δy, Δx) turned into (−π ÷ 2, π ÷ 2]

    Schematic wires, pins and connections addons/electrical/lib/wires.js
    • CadCraft
    64-bit
  • Which wire a wire number belongs to

    Assigns each wire number to the nearest wire within reach.

    nearest segment with d² ≤ 3²

    Schematic wires, pins and connections addons/electrical/lib/wires.js
    • CadCraft
    64-bit
  • Junction dots

    Places a dot at each junction and removes dots that no longer mark one.

    a dot marks a junction when d² ≤ max(tol, 0.2)²

    Schematic wires, pins and connections addons/electrical/lib/wires.js
    • CadCraft
    64-bit
  • Transform of a placed symbol

    The matrix that takes a symbol's own coordinates to the drawing.

    a = cos r × sx; b = sin r × sx; c = −sin r × sy; d = cos r × sy; e = x − (a bₓ + c b_y); f = y − (b bₓ + d b_y)

    Schematic wires, pins and connections addons/electrical/lib/symbols.js
    • CadCraft
    64-bit
  • A point through the transform

    Applies a symbol's matrix to a point.

    x′ = a x + c y + e; y′ = b x + d y + f

    Schematic wires, pins and connections addons/electrical/lib/symbols.js
    • CadCraft
    64-bit
  • Pin positions of a placed symbol

    The drawing positions of a symbol's connection points.

    Schematic wires, pins and connections addons/electrical/lib/symbols.js
    • CadCraft
    64-bit
  • Pin offsets written to the block

    Formats a pin offset for the block's EL attribute text.

    text = round(n × 1000) ÷ 1000

    Schematic wires, pins and connections addons/electrical/lib/symbols.js
    • CadCraft
    64-bit
  • Attribute text kept upright

    Decides which attribute texts of a rotated symbol would read upside down and turns them half round.

    turn when cos(rot + text rot) ≤ −1e-9

    Schematic wires, pins and connections addons/electrical/lib/symbols.js
    • CadCraft
    64-bit
  • Sheet points on the 2.5 mm grid

    Moves a picked point on a sheet to the nearest point of the 2.5 mm grid.

    x = round(x ÷ 2.5) × 2.5

    Schematic wires, pins and connections addons/electrical/main.js
    • CadCraft
    Exact
  • A wire point landing on a pin or wire

    Moves a picked wire point onto a pin, a wire end or a wire when it is within 2 units of one.

    candidate when d² ≤ 2²; a wire's middle is ranked with d² + 0.25

    Schematic wires, pins and connections addons/electrical/main.js
    • CadCraft
    64-bit
  • A wire cut under a new symbol

    Cuts a wire between two pins of a symbol placed on it.

    pin on the wire when d² < 1e-4 and 1e-6 < u < 1 − 1e-6

    Schematic wires, pins and connections addons/electrical/main.js
    • CadCraft
    64-bit
  • PV one-line layout

    Positions the symbols and wires of a solar one-line diagram from the column and row of each node.

    x = x₀ + col × pitch x; y = y₀ − row × pitch y; wire bend at (sx + ex) ÷ 2

    Schematic wires, pins and connections addons/electrical/lib/pvoneline.js
    • CadCraft
    64-bit
  • Transform of a schematic symbol

    The matrix that takes a symbol's pin offsets to the drawing.

    a = cos r × sx; b = sin r × sx; c = −sin r × sy; d = cos r × sy; e = x − (a bₓ + c b_y); f = y − (b bₓ + d b_y)

    Wire harness and control cabinet layout addons/harness/lib/schem.js
    • CadCraft
    64-bit
  • Squared distance from a point to a wire segment

    How far a wire end or pin is from a wire segment.

    u = clamp((p − a)·(b − a) ÷ |b − a|², 0, 1); d² = |p − (a + u (b − a))|²

    Wire harness and control cabinet layout addons/harness/lib/schem.js
    • CadCraft
    64-bit
  • Which wires and pins are connected

    Joins wire ends to other ends, to pins and to wires they touch, to find the nets.

    connected when distance² ≤ tol², tol = 0.05

    Wire harness and control cabinet layout addons/harness/lib/schem.js
    • CadCraft
    64-bit
  • A point in a rail's frame

    The distance along a rail and off its axis of a drawing point, in millimeters.

    s = (Δx cos r + Δy sin r) ÷ k; off = (−Δx sin r + Δy cos r) ÷ k

    Wire harness and control cabinet layout addons/harness/lib/cabinet.js
    • CadCraft
    64-bit
  • A rail position back in the drawing

    The drawing point at a distance along a rail.

    x = x₀ + (s cos r − off sin r) × k; y = y₀ + (s sin r + off cos r) × k

    Wire harness and control cabinet layout addons/harness/lib/cabinet.js
    • CadCraft
    64-bit
  • Modules on a rail

    Which modules sit on a rail, and the stretch of rail each covers.

    s₀ = s − w ÷ 2; s₁ = s + w ÷ 2

    Wire harness and control cabinet layout addons/harness/lib/cabinet.js
    • CadCraft
    64-bit
  • Modules past the end or overlapping

    Flags a module that hangs past the rail or overlaps the next one.

    past when s₀ < −0.01 or s₁ > len + 0.01; overlap when next s₀ < s₁ − 0.01

    Wire harness and control cabinet layout addons/harness/lib/cabinet.js
    • CadCraft
    64-bit
  • Free length on a rail

    The rail length not taken by modules.

    free = max(0, len − Σ module widths)

    Wire harness and control cabinet layout addons/harness/lib/cabinet.js
    • CadCraft
    64-bit
  • Where a new module sits

    The center of a new module on a rail: inside the rail, and flush to a neighbor when close.

    c = clamp(s, w ÷ 2, len − w ÷ 2); c = neighbor edge ± w ÷ 2 when within 3 mm

    Wire harness and control cabinet layout addons/harness/lib/cabinet.js
    • CadCraft
    64-bit
  • Drawing units per millimeter

    The factor between the drawing and millimeters.

    k = (1 ÷ per) × (1 ÷ 25.4 for inch rules)

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • A harness moved, turned or scaled

    Applies a move, rotation or scale to a harness: its nodes and its scale.

    k′ = k × √(m₀² + m₁²); node′ = M · node

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • Module positions in millimeters

    Each placed module's position for routing wires to it.

    x mm = x ÷ k; y mm = y ÷ k

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • Total length of a harness

    The summed length of a harness's segments for the bill of materials.

    mm = Σ segment length

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • Wire count and bundle diameter per segment

    The number of wires in each harness segment and the diameter of their bundle, kept on the harness.

    od = round(bundleDiameter × 10) ÷ 10

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • Rail length and angle from two points

    The length in millimeters and the angle of a rail drawn between two points.

    len = √(Δx² + Δy²) ÷ k; rot = atan2(Δy, Δx)

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • Modules placed in a row

    Places every remaining module along a rail, one after the other.

    center = s + w ÷ 2; s ← s + w; stop when s + w > len + 1e-9

    Wire harness and control cabinet layout addons/harness/main.js
    • CadCraft
    64-bit
  • Segment length and bundle labels

    The length written beside each harness segment, and its wire count and diameter.

    mm = typed length, or √(Δx² + Δy²) ÷ k; label = round(mm)

    Wire harness and control cabinet layout addons/harness/lib/draw.js
    • CadCraft
    64-bit
  • A run moved, turned or scaled

    Applies a move, rotation, scale or mirror to a run's centerline and its scale.

    p′ = M · p; sc = √|det M|; k′ = k ÷ sc; z′ = z × sc

    Duct runs, fittings and schedule addons/hvac/lib/duct.js
    • CadCraft
    64-bit
  • Section width in drawing units

    The drawn width of a duct section.

    width = w ÷ k

    Duct runs, fittings and schedule addons/hvac/lib/duct.js
    • CadCraft
    64-bit
  • Elbows, transitions and straight pieces

    The fittings of a run and the start and end of each straight piece along its centerline.

    T = R tan(θ ÷ 2), R = r × W; mitred: T = (W ÷ 2) tan(θ ÷ 2); elbow length = R θ or 2T; transition L = max(max(ΔW ÷ 2, ΔH) ÷ tan 15° ÷ k, minimum)

    Duct runs, fittings and schedule addons/hvac/lib/duct.js
    • CadCraft
    64-bit
  • Length in feet or meters

    Converts a length in drawing units to feet or meters.

    feet = du × k ÷ 12; meters = du × k ÷ 1000

    Duct runs, fittings and schedule addons/hvac/lib/duct.js
    • CadCraft
    64-bit
  • Sheet-metal area of a length of duct

    The surface area of a length of duct in square feet or square meters.

    ft² = perimeter × du × k ÷ 144; m² = perimeter × du × k ÷ 1e6

    Duct runs, fittings and schedule addons/hvac/lib/duct.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.