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.
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
Pipe resistance and minor-loss coefficients
The two coefficients each pipe carries into the solver: friction resistance and minor loss.
r = 10.67 × L ÷ (C^1.852 × D^4.871); m = 8K ÷ (π² g D⁴)
Water mains network: heads, flows and pressures water.js64-bit- CivilCraft
-
Head loss and its gradient for one link
The head loss across a pipe, valve or pump at the current flow, and its derivative, for each solver pass.
pipe: f = (r·|q|^0.852 + m·|q|)·q, g = 1.852·r·|q|^0.852 + 2·m·|q|; pump: f = −(H₀ − r·qⁿ), g = r·n·qⁿ⁻¹
Water mains network: heads, flows and pressures water.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
Signed polygon area
The signed area of a closed outline.
A = −½ Σ (xⱼ + xᵢ)(yⱼ − yᵢ)
Outline minus holes: area and boundary lengths landscape/areas.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
Fingerprint of the source points
A short code that changes when the source linework moves, so the linked object knows to update.
hash of round(x × 10⁶), round(y × 10⁶) for every point
Linework checks for linked landscape objects landscape/links.js64-bit- CivilCraft
-
Clean and check a line or outline
Drops repeated points, closes an outline and refuses linework that is too short, too far away, open or self-crossing.
Linework checks for linked landscape objects landscape/links.js64-bit- CivilCraft
-
Self-crossing test
Whether any two edges of the line cross away from their ends.
Linework checks for linked landscape objects landscape/links.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js32-bit, display only- CivilCraft
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.