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

  • A click landing on a connection, end or line

    Finds the connection point, line end or point on a line within reach of a click.

    nearest within tol; a point on a line is ranked with distance + 0.1 × tol

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • A line cut around an inline symbol

    Cuts a process line either side of a symbol placed on it, so the symbol's ends meet the line's.

    u = (b − a) ÷ |b − a|; cut points = at ± u × half

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • A symbol's connection landed on a picked point

    Moves a new symbol so its nearest connection sits exactly on the connection or line end that was clicked.

    offset = R(rot) · connection × size; at = picked − offset

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • Scale of an imported DEXPI drawing

    The drawing units per millimeter used to place an imported P&ID.

    k = 1 ÷ (millimeters per drawing unit)

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • Imported stream table values

    Converts stream temperature, pressure and flows to display units and writes them into a table in the drawing.

    °C = K − 273.15 (1 decimal); bar = Pa ÷ 1e5 (3); kg/h = kg/s × 3600 (1); kmol/h = mol/s × 3.6 (3); fractions 3 and 4 decimals

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • Drawing coordinates for the area calculator

    Hands the symbols' positions and the meters per drawing unit to the hazardous-area calculator.

    toMetres = (millimeters per drawing unit) ÷ 1000

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • Consequence zones drawn to scale

    Draws each zone of the consequence calculator as a circle or polygon at the picked point.

    k = 1000 ÷ (millimeters per drawing unit); center = at + (cx, cy) × k; radius = r × k

    P&ID placement, zones and values written to the drawing addons/pid/main.js
    • CadCraft
    64-bit
  • Relief valve area written to the symbol

    Sizes a relief valve with the relief calculator and writes its orifice letter and area on the symbol.

    area_mm2 = round(A × 1e6)

    P&ID placement, zones and values written to the drawing addons/pid/main.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
  • 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

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.