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

  • Angular misclosure and leg directions

    The angular misclosure of a loop and the direction of each leg after the angles are corrected.

    misclosure = ((again − first) mod 360 + 540) mod 360 − 180; per angle = −misclosure ÷ n; az(i) = az(i − 1) + 180 + angle(i) + per angle

    Traverse closure and compass adjustment traverse.js
    • CivilCraft
    64-bit
  • Station coordinates and linear misclosure

    The unadjusted coordinates of each station, the misclosure at the end and the traverse's precision.

    x += d·cos(dir); y += d·sin(dir); misclosure = √(Δx² + Δy²); precision = total length ÷ misclosure

    Traverse closure and compass adjustment traverse.js
    • CivilCraft
    64-bit
  • Compass rule adjustment

    Moves each station against the misclosure in proportion to the distance run to reach it.

    cx = −Δx × run ÷ length; cy = −Δy × run ÷ length; adjusted = unadjusted + correction

    Traverse closure and compass adjustment traverse.js
    • CivilCraft
    64-bit
  • Traverse report as CSV

    Writes the closure and every station's unadjusted and adjusted coordinates and corrections.

    coordinates and corrections to 4 decimals; distances and length to 3; precision as 1 : whole number; angles to whole seconds

    Traverse closure and compass adjustment traverse.js
    • CivilCraft
    64-bit
  • Frog angle from the frog number

    The angle at which the diverging track leaves, from the frog number.

    θ = 2·atan(1 ÷ (2N))

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Turnout radius, lead and centerline

    The closure radius, the lead and the centerline points of the diverging track.

    R = (g − s·sin β) ÷ (cos β − cos θ); lead = s·cos β + R·(sin θ − sin β); arc length = R·(θ − β)

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Crossover between parallel tracks

    The straight between two turnouts that join parallel tracks, and the overall length.

    straight = (spacing − 2g) ÷ sin θ; length = 2 × lead + straight × cos θ

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Speed on the diverging route

    The speed for a radius, cant and cant deficiency.

    V = √(R·(E + D) ÷ (rail ÷ 127.12)) km/h; rail = 1500 mm gives 11.8

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Vehicle throw on a curve

    How far the middle of a vehicle moves in and its ends move out on a curve.

    inside = b² ÷ (8R); outside = (L² − b²) ÷ (8R)

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Clearance outline on a canted curve

    The vehicle or structure outline tilted by the cant and widened by the curve throw.

    tilt = asin(min(1, cant ÷ base)); rotate each point about the low rail; shift by the inside or outside throw

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Least track spacing for two outlines

    The smallest center spacing at which two clearance outlines do not overlap.

    bisection on the shift between 0 and 20, 60 halvings

    Railway turnouts, crossovers and clearance envelopes turnout.js
    • CivilCraft
    64-bit
  • Turn angle at a junction

    The angle a main turns through at a junction of two pipes.

    turn = |atan2 of the leg after − atan2 of the leg before|, folded to 0 to 180 degrees

    Water mains as objects: depths, fittings and take-off water-objects.js
    • CivilCraft
    64-bit
  • Pipe depths and derived fittings

    The elevation of each pipe end, the position of placed objects along pipes, and the fittings the layout implies.

    z = ground − cover; on a pipe: p = a + (b − a)·t; length = stated, else √(Δx² + Δy²); bend angle rounded to 0.1°

    Water mains as objects: depths, fittings and take-off water-objects.js
    • CivilCraft
    64-bit
  • Take-off of pipes and fittings

    The count of each fitting by kind and size and the count and total length of pipe by size.

    length per size = Σ pipe lengths

    Water mains as objects: depths, fittings and take-off water-objects.js
    • CivilCraft
    64-bit
  • Take-off as CSV

    Writes the take-off list to a CSV file.

    length = round(length × 100) ÷ 100; size to 1 decimal

    Water mains as objects: depths, fittings and take-off water-objects.js
    • CivilCraft
    64-bit
  • Ground elevation of a new node

    The elevation stored on a junction, reservoir or tank when it is placed on the plan.

    z = round(ground × 100) ÷ 100; reservoir head = z + 30 (m) or 100 (ft)

    Water mains as objects: depths, fittings and take-off water-ui.js
    • CivilCraft
    64-bit
  • Unit factors

    The factors that turn project units (ft, in, gpm, psi or m, mm, L/s, kPa) into the SI values the solver works in.

    ft = 0.3048 m; in = 0.0254 m; gpm = 6.30902e-5 m³/s; psi per ft = 0.433527; kPa per m = 9.80665

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Pump curve fit

    Turns one or three pump curve points into the head a pump adds at any flow.

    H = H₀ − r·Qⁿ; n = ln((H₀ − H₂) ÷ (H₀ − H₁)) ÷ ln(Q₂ ÷ Q₁); r = (H₀ − H₁) ÷ Q₁ⁿ

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Hazen-Williams head loss

    The friction head loss in a pipe for a given flow, length, diameter and C factor, in SI.

    h = 10.67 × L × |Q|^1.852 ÷ (C^1.852 × D^4.871) × sign(Q)

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Node equations for one pass

    Builds the linear system for the unknown heads from the link coefficients, demands and fixed heads, and solves it.

    Q = P·(Hₐ − H_b) + Y; P = 1 ÷ g; Y = Q − f ÷ g; Σ flows at each node = demand

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Flow update and convergence test

    Updates every link flow from the new heads and decides when the network is solved.

    stop when Σ|Q_new − Q_old| ÷ Σ|Q_new| < 1e−7 and no valve or pump changed status

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Linear solve for the heads

    Solves the symmetric positive definite system for the unknown node heads.

    A = L·Lᵀ, forward and back substitution; or conjugate gradient with z = r ÷ diag(A)

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Heads, pressures, velocities and head loss per 1000

    The numbers shown for each node and pipe, converted back to project units, and the limit checks on them.

    pressure = (H − z) × p factor; v = |Q| ÷ (π D² ÷ 4); loss per 1000 = |Hₐ − H_b| ÷ (L ÷ 1000)

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Available fire flow

    The largest draw at one node that keeps the lowest pressure in the network at or above the residual pressure.

    bisection on the draw: 40 halvings of [lo, hi], each one a full network solve

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Tank levels over time

    Steps the network through the day and moves each tank level by the flow into it.

    level₊ = level + inflow × Δt ÷ (π d² ÷ 4), clamped to [min level, max level]

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • EPANET-format export

    Writes the network as EPANET-format text for other programs.

    written value = round(v × 10⁴) ÷ 10⁴

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Lot outline with arcs as chords

    The lot as a counter-clockwise ring of points, each tagged with the lot line it starts.

    chord angle = 2·acos(1 − 0.01 ÷ R); n = ⌈Δ ÷ chord angle⌉, 2 ≤ n ≤ 400

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Setback distance for each lot line

    Assigns the front, side or rear distance, or a typed distance, to every lot line, and picks the rear line when none is named.

    rear = the line with −cos(dir − front dir) > 0.5 whose midpoint is farthest from the front line's midpoint

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Buildable envelope and its area

    The lot taken in from every line by that line's setback, with its area, or the reason it cannot be built.

    area = |shoelace(envelope)|; lot area = |shoelace(lot ring)|

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Mitred inset with a distance per line

    Moves each lot line in by its own distance and finds each new corner where two moved lines meet.

    s = ((q − p) × u_q) ÷ (u_p × u_q); corner = p + s·u_p

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Allowed height under a sky-exposure plane

    The lowest height the cap and the sky-exposure plane allow over a footprint.

    s = ((p − a) × (b − a)) ÷ |b − a|; h = h₀ + rise × max(0, s); allowed = min over corners and lines

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Footprint area inside the envelope

    How much of a building footprint lies inside the buildable envelope.

    area = Σ over envelope triangles of |shoelace(footprint clipped to the triangle)|

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Clip a footprint to one triangle

    The part of a polygon inside a convex, counter-clockwise piece.

    side(p) = (b − a) × (p − a); crossing at u = s_p ÷ (s_p − s_q)

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Coverage, floor area ratio, setback and height checks

    Compares the masses on a lot with every limit typed for it and lists each result.

    coverage = Σ footprint ÷ lot area; FAR = Σ floor area ÷ lot area; outside = footprint − inside area

    Zoning envelope and limit checks zoning.js
    • CivilCraft
    64-bit
  • Signed polygon area

    The signed area of a closed outline.

    A = −½ Σ (xⱼ + xᵢ)(yⱼ − yᵢ)

    Outline minus holes: area and boundary lengths landscape/areas.js
    • CivilCraft
    64-bit
  • Point inside a polygon

    Whether a point lies inside an outline, used to keep or drop each boundary piece.

    count edges with (aᵧ > y) ≠ (bᵧ > y) and x < x on the edge at height y

    Outline minus holes: area and boundary lengths landscape/areas.js
    • CivilCraft
    64-bit
  • Where two segments cross

    The position along one edge where another edge crosses or touches it.

    t = ((c − a) × s) ÷ (r × s); u = ((c − a) × r) ÷ (r × s)

    Outline minus holes: area and boundary lengths landscape/areas.js
    • CivilCraft
    64-bit
  • Area by slabs

    The area of the outline with every hole removed, overlaps counted once.

    area = Σ over slabs of (width inside the outline and outside all holes at mid-height) × slab height

    Outline minus holes: area and boundary lengths landscape/areas.js
    • CivilCraft
    64-bit
  • Outline and cut lengths

    The pieces of the outline that remain and the pieces of the holes that cut it, with their total lengths.

    length = Σ |b − a| over kept pieces; a = e.a + t₀(e.b − e.a), b = e.a + t₁(e.b − e.a)

    Outline minus holes: area and boundary lengths landscape/areas.js
    • CivilCraft
    64-bit
  • STL reader

    Turns a binary or ASCII STL file into a mesh with shared vertices, scaled to millimeters.

    Freeform mesh objects: quantities and placement on the ground landscape/freeform.js
    • CivilCraft
    64-bit
  • Volume, surface area, footprint and height

    The quantities of a mesh object that schedules and the IFC export report.

    V = |Σ v₀·(v₁×v₂)| ÷ 6; A = Σ |(v₁−v₀)×(v₂−v₀)| ÷ 2; height = z max − z min

    Freeform mesh objects: quantities and placement on the ground landscape/freeform.js
    • CivilCraft
    64-bit
  • Convex hull of the plan points

    The outline used as the object's footprint on the plan.

    keep a turn when (a − o) × (b − o) > 0

    Freeform mesh objects: quantities and placement on the ground landscape/freeform.js
    • CivilCraft
    64-bit
  • Mesh millimeters to project coordinates

    Places a mesh point on the site: scaled to project units, turned by the object's rotation and moved to its insertion point.

    x = x₀ + (x·cos a − y·sin a) × k; k = 1 ÷ (1000 × meters per project unit)

    Freeform mesh objects: quantities and placement on the ground landscape/freeform.js
    • CivilCraft
    64-bit
  • Base elevation and volume below ground

    The elevation the object's base sits at, its points in project coordinates, and an estimate of how much of it is below the existing ground.

    follow: base = lowest ground sample; cut: base = typed level or mean of the samples; below ≈ Σ (ground − base) × cell²

    Freeform mesh objects: quantities and placement on the ground landscape/freeform.js
    • CivilCraft
    64-bit
  • Positions and indices from an accessor

    Reads a primitive's vertex positions and triangle indices from the file's binary chunk.

    Plant 3D models for the 3D view landscape/glb.js
    • CivilCraft
    32-bit, display only

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.