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 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
  • Symbol drawn at its size

    Scales the unit-size symbol shapes to the placed symbol's length.

    v′ = v × k

    P&ID line geometry and connections addons/pid/lib/symbols.js
    • CadCraft
    64-bit
  • Symbol turned and moved

    Rotates symbol entities about the origin and moves them to a point.

    x′ = pₓ + x cos θ − y sin θ; y′ = p_y + x sin θ + y cos θ

    P&ID line geometry and connections addons/pid/lib/symbols.js
    • CadCraft
    64-bit
  • Drawing units to millimeters on export

    Converts every exported symbol position, line vertex and symbol size to millimeters.

    mm = round(v × mmPerUnit, 3 decimals)

    DEXPI and PCF plant exchange files addons/pid/lib/dexpi-pid.js
    • CadCraft
    • BimCraft
    64-bit
  • Drawing extent on export

    The width and height stated for the exported drawing.

    w = ceil(mm(max x) + 50); h = ceil(mm(max y) + 50)

    DEXPI and PCF plant exchange files addons/pid/lib/dexpi-pid.js
    • CadCraft
    • BimCraft
    64-bit
  • Symbol position and size on import

    Places an imported plant item in the drawing at the file's position and size.

    x = x_file × perMm; l = SymbolSize × perMm

    DEXPI and PCF plant exchange files addons/pid/lib/dexpi-pid.js
    • CadCraft
    • BimCraft
    64-bit
  • Line ends moved onto connections on import

    Moves an imported line end onto the nearest symbol connection when it is close enough.

    moved when distance ≤ 0.6 × symbol size

    DEXPI and PCF plant exchange files addons/pid/lib/dexpi-pid.js
    • CadCraft
    • BimCraft
    64-bit
  • Numbers read from DEXPI attributes

    Turns an attribute's text into a number.

    DEXPI and PCF plant exchange files addons/pid/lib/interop/dexpi.js
    • CadCraft
    • BimCraft
    64-bit
  • Position and rotation of a plant item

    The location of an item and its rotation in the plane, read from its Position element.

    rotation = atan2(Reference.Y, Reference.X)

    DEXPI and PCF plant exchange files addons/pid/lib/interop/dexpi.js
    • CadCraft
    • BimCraft
    64-bit
  • Position and direction written to DEXPI

    Writes an item's location and its direction vector.

    Reference = (round(cos θ, 9 decimals), round(sin θ, 9 decimals), 0)

    DEXPI and PCF plant exchange files addons/pid/lib/interop/dexpi.js
    • CadCraft
    • BimCraft
    64-bit
  • Numbers written to PCF

    How a coordinate or a bore is written in a PCF file.

    text = round(n, 4 decimals)

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • End point lines read from PCF

    Reads a component's end point: three coordinates, a bore and an end type.

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • PCF units to millimeters

    Converts coordinates and bores from the units named in the file header to millimeters.

    x_mm = x × factor; factors: inch 25.4, foot 304.8, meter 1000, cm 10

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • Bend angle read from PCF

    Reads a component's angle in degrees.

    angle = value ÷ 100

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • Geometry checks on a PCF file

    Flags pipes with no length, elbows whose center is not equally far from both ends, and straight parts that change bore.

    |r₀ − r₁| > 0.01 × max(r₀, r₁, 1)

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • Length of a PCF component

    The straight distance between a component's two end points, in millimeters.

    length = √(Δx² + Δy² + Δz²)

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • Which PCF components meet

    Finds end points and branch points that coincide, and the ends left open.

    joined when √(Δx² + Δy² + Δz²) ≤ tol

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • Point lines written to PCF

    Writes an end point, branch point or center point line.

    DEXPI and PCF plant exchange files addons/pid/lib/interop/pcf.js
    • CadCraft
    • BimCraft
    64-bit
  • Size units per drawing unit

    How many inches or millimeters one drawing unit is.

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

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Feet per drawing unit

    The factor that turns drawing units into feet for the takeoff export.

    feet = (meters per drawing unit) ÷ 0.3048

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Segments of a run

    Each straight stretch of a run with its length, unit direction, left normal and distance from the start.

    t = (b − a) ÷ |b − a|; n = (−t_y, t_x); s₀ = Σ earlier lengths

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Point at a distance along a run

    The point a given distance along the centerline.

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Nearest point on a run

    The point of a run's centerline closest to a given point.

    at = clamp((p − a)·t, 0, length)

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Turn between two directions

    The signed angle from one direction to the next.

    turn = atan2(t₁ × t₂, t₁ · t₂)

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Bend at a corner

    Where an elbow starts and ends, its center and its angles.

    T = R × tan(θ ÷ 2); p₁ = V − t_in T; p₂ = V + t_out T; c = p₁ + n_in R

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Cross-section outline

    The points of a rectangular, round or flat-oval section used to build the 3D solid.

    round: (r cos a, r + r sin a), a = −¾π + 2πj ÷ N

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Signed volume of a closed mesh

    The volume enclosed by a set of polygons, positive when the faces point outward.

    V = Σ a · (b × c) ÷ 6 over the fan triangles of each face

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Solid through a row of sections

    One closed solid from the cross-sections along a run, with its two ends capped.

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Numbers in CSV exports

    How a number cell is written in a CSV file.

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Takeoff mark coordinates

    Rounds the points of each takeoff mark before they are stored in the takeoff project.

    v′ = round(v × 10⁶) ÷ 10⁶

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Scale of the takeoff sheet

    Feet per PDF point for the sheet the takeoff is measured on, and the mapping of drawing points to PDF points.

    K = 72 ÷ 25.4; feet per point = (feet per drawing unit) ÷ (m₀ × K)

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/mep-core.js
    • CadCraft
    64-bit
  • Cleaning a run's data

    Checks a run's points, sizes, elevation, slope and valves before the run is stored.

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Move, rotate, scale or mirror a run

    The run's points, scale, elevation, symbol size and valve positions after a transform.

    s = √|m₀m₃ − m₁m₂|; k′ = k ÷ s; z′ = z × s

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Elevation along a run

    The centerline elevation a given plan distance along the run.

    z(s) = z₀ − slope × s

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Elbows, reducers and trimmed pieces

    Places an elbow at each turn and a reducer at each size change, and trims the straight pieces to fit.

    T = R × tan(θ ÷ 2); reducer length = 1.5 × max(OD₁, OD₂)

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Sections for the 3D pipe

    The cross-sections along the centerline that the 3D solid is built from.

    elbow steps = max(2, ceil(θ ÷ 15°)); z = z₀ − slope × s − OD ÷ 2

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Drawing units to feet or meters, and the slope factor

    Converts a plan length to feet or meters and corrects it for the run's slope.

    ft = du × k ÷ 12; m = du × k × 25.4 ÷ 1000; factor = √(1 + slope²)

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Pipe length by size

    The length of pipe of each size in a run, in plan and along the slope.

    len = Σ lenOut(segment) × √(1 + slope²)

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Schedule totals

    Pipe length and steel weight by material and size, fitting counts, and the totals.

    weight = (weight per length) × length; total = Σ rows

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Slope label

    The slope written on the drawing and in the schedule: a fraction of an inch per foot, or a percentage.

    in/ft = slope × 12; % = slope × 100

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Plan of a run

    The lines and arcs drawn for a run: a single centerline, or two side lines with elbow arcs and reducers.

    side line = centerline ± n × OD ÷ 2; elbow arcs at R ± OD ÷ 2

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Size label

    The size written beside a pipe: NPS, DN, or a tube size with its outside diameter in millimeters.

    mm = OD (in) × 25.4

    Pipe runs: layout, 3D solid and schedule addons/piping/lib/pipe.js
    • CadCraft
    64-bit
  • Typed pipe size

    Matches what a person types (2, 1-1/2, 1.5, DN50) to a size of the pipe table.

    Pipe runs: layout, 3D solid and schedule addons/piping/main.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.