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

  • 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
  • Length of a position

    The length of a pipe, truss or floor line along its points.

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

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/model.js
    • CadCraft
    64-bit
  • Where a point is on a position

    The distance along a position to the point nearest a fixture, and the fixture's distance from the line.

    u = clamp((p − a)·(b − a) ÷ |b − a|², 0, 1); s = length before + u × |b − a|; off = |p − q|

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/model.js
    • CadCraft
    64-bit
  • Position a fixture belongs to

    The nearest named position within reach of a point.

    nearest with off ≤ tol

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/model.js
    • CadCraft
    64-bit
  • Fixture data checked

    Checks a fixture's stored data: scale, wattage, DMX footprint and aim angle.

    aim = ((aim mod 360) + 360) mod 360

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/model.js
    • CadCraft
    64-bit
  • Wattage of a fixture

    The watts of a fixture: its own value, or its type's typical value.

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/model.js
    • CadCraft
    64-bit
  • Point at a distance along a position

    The drawing point a given distance along a position's line.

    u = clamp((s − run) ÷ l, 0, 1); p = a + (b − a) × u

    Stage lighting plot: positions, fixtures and loads addons/lighting/main.js
    • CadCraft
    64-bit
  • Fixtures spread along a position

    Places n fixtures evenly along a position.

    sᵢ = L × (i + 0.5) ÷ n

    Stage lighting plot: positions, fixtures and loads addons/lighting/main.js
    • CadCraft
    64-bit
  • A position moved, turned or scaled

    Applies a move, rotation or scale to a position's points and its scale.

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

    Stage lighting plot: positions, fixtures and loads addons/lighting/main.js
    • CadCraft
    64-bit
  • Fixture symbol turned to its aim

    Rotates a fixture's symbol by its aim angle.

    x′ = x cos a − y sin a; y′ = x sin a + y cos a

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/draw.js
    • CadCraft
    64-bit
  • Position length in millimeters

    The length of a position for the schedule and the capacity warning.

    mm = length in drawing units ÷ k

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/draw.js
    • CadCraft
    64-bit
  • Legend totals

    The total number of fixtures and total watts at the foot of the legend.

    total = Σ count; total watts = Σ watts

    Stage lighting plot: positions, fixtures and loads addons/lighting/lib/draw.js
    • CadCraft
    64-bit
  • A drawing object as a nest loop

    Turns a circle or closed polyline into a loop of points with bulges.

    circle = (cx + r, cy) and (cx − r, cy), each with bulge 1

    Nesting add-on: outlines in, placed copies out addons/nesting/lib/parts.js
    • CadCraft
    64-bit
  • Outline as chords for containment

    Points along an outline, with each arc as 8 chords, used to test which outline contains which.

    θ = 4 atan(b); r = c ÷ (2 sin(θ ÷ 2)); center = chord middle + normal × r cos(θ ÷ 2)

    Nesting add-on: outlines in, placed copies out addons/nesting/lib/parts.js
    • CadCraft
    64-bit
  • Parts and their holes

    Groups outlines into parts with holes and moves each part to its own corner.

    parent = smallest larger outline containing the first point; shifted point = p − (x₀, y₀)

    Nesting add-on: outlines in, placed copies out addons/nesting/lib/parts.js
    • CadCraft
    64-bit
  • A part's object placed on the sheet

    Moves and turns one object of a part to where the engine placed it.

    q = at + (x, y) + R(rot) · (p − origin)

    Nesting add-on: outlines in, placed copies out addons/nesting/lib/parts.js
    • CadCraft
    64-bit
  • Sheet rectangles and labels

    A rectangle for each sheet, side by side, and the part names over the copies.

    xₖ₊₁ = xₖ + w + gap, gap = max(20, 0.1 × h) by default; label at the mean of the outline's points

    Nesting add-on: outlines in, placed copies out addons/nesting/lib/parts.js
    • CadCraft
    64-bit
  • Size units per drawing unit

    How many inches or millimeters one drawing unit is, from the drawing's unit setting.

    factor = (meters per drawing unit) ÷ 0.0254 or ÷ 0.001

    P&ID line geometry and connections addons/pid/lib/core.js
    • CadCraft
    64-bit
  • Length of a line

    The length of a P&ID line along its corner points.

    length = Σ √(Δxᵢ² + Δyᵢ²)

    P&ID line geometry and connections addons/pid/lib/core.js
    • CadCraft
    64-bit
  • Nearest point on a line

    The point of a line closest to a given point, its distance, and how far along the line it lies.

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

    P&ID line geometry and connections addons/pid/lib/core.js
    • CadCraft
    64-bit
  • Label position on the longest segment

    The middle and direction of a line's longest segment, where its line number is written.

    mid = (a + b) ÷ 2; angle = atan2(Δy, Δx)

    P&ID line geometry and connections addons/pid/lib/core.js
    • CadCraft
    64-bit
  • Numbers in CSV exports

    How a number cell is written when a P&ID list is exported as CSV.

    P&ID line geometry and connections addons/pid/lib/core.js
    • CadCraft
    64-bit
  • Cleaning a line's points

    Checks a line's data and removes repeated corner points before it is stored.

    P&ID line geometry and connections addons/pid/lib/lines.js
    • CadCraft
    64-bit
  • Line ends and their directions

    The two end points of a line and the direction in which the line leaves each.

    a = atan2(end − neighbor)

    P&ID line geometry and connections addons/pid/lib/lines.js
    • CadCraft
    64-bit
  • Move, rotate, scale or mirror a line

    The line's points, symbol size and text height after a transform.

    x′ = m₀x + m₂y + m₄; y′ = m₁x + m₃y + m₅; s = √|m₀m₃ − m₁m₂|

    P&ID line geometry and connections addons/pid/lib/lines.js
    • CadCraft
    64-bit
  • Symbol connection points in the drawing

    Turns a point of a symbol's own frame into drawing coordinates using the symbol's position, rotation and scale.

    x′ = x₀ + (x·sx)·cos θ − (y·sy)·sin θ; y′ = y₀ + (x·sx)·sin θ + (y·sy)·cos θ

    P&ID line geometry and connections addons/pid/lib/model.js
    • CadCraft
    64-bit
  • Connection tolerance

    How close a line end must be to a connection point, a line end or a line for the two to count as joined.

    tol = 0.04 × max(size a, size b, 1e-6); joined when √(Δx² + Δy²) ≤ tol

    P&ID line geometry and connections addons/pid/lib/model.js
    • CadCraft
    64-bit
  • Candidate search grid

    Limits which symbol connections and lines are tested against each line end.

    cell = max(tol of the largest size, 1e-9); index = floor(v ÷ cell)

    P&ID line geometry and connections addons/pid/lib/model.js
    • CadCraft
    64-bit
  • Line end on the body of another line

    Decides whether a line end lands on another line between its ends, which makes it a branch.

    u = clamp((p − a)·(b − a) ÷ |b − a|², 0, 1); hit when |p − (a + u (b − a))| ≤ tol

    P&ID line geometry and connections addons/pid/lib/model.js
    • CadCraft
    64-bit
  • Connection points of a symbol

    Where lines attach to a placed symbol, in the symbol's own frame.

    x = x_unit × l; y = y_unit × l

    P&ID line geometry and connections addons/pid/lib/symbols.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.