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

  • Flow at a station

    The flow that applies at a station, from the profile's flow and its flow changes.

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • First guess of the boundary slope

    The slope offered for a normal-depth boundary when one is first chosen, from the lowest points of the end sections.

    S = (z_min upstream − z_min downstream) ÷ (rs upstream − rs downstream), to 3 significant digits; 0.001 when S ≤ 1e-5

    River model: stations, cut sections and reach lengths river-ui.js
    • CivilCraft
    64-bit
  • Least-cost search

    Searches the grid for the cheapest allowed path and returns its points and total cost.

    grade = |z₂ − z₁| ÷ length ≤ limit; cost = length × unit cost × factor × (1 + w·(grade ÷ limit)²) + area × length × earth cost

    Best route across the terrain route.js
    • CivilCraft
    32-bit in part
  • Path points and their elevations

    Turns the chain of grid cells into the route's points, with the two ends at the picked points and collinear points removed.

    x = minX + (i + 0.5) × cell; collinear when |cross product| < 1e-9 × cell²

    Best route across the terrain route.js
    • CivilCraft
    32-bit in part
  • Route length, steepest grade and earthwork

    The length, steepest grade, cut and fill along a finished route.

    length = Σ √(Δx² + Δy²); grade = |Δz| ÷ l; s = |z_left − z_right| ÷ width; area = width²·s ÷ 4 ÷ max(0.05, 1 − sideSlope·s); volume += area × l ÷ n

    Best route across the terrain route.js
    • CivilCraft
    64-bit
  • Curve radius at each bend

    The turn angle and the radius implied at each bend of the route.

    turn = atan2 of the leg after − atan2 of the leg before, wrapped to (−π, π]; radius = (l₁ + l₂) ÷ (2|turn|)

    Best route across the terrain route.js
    • CivilCraft
    64-bit
  • Route profile

    Distance along the route against elevation, for the profile drawing and the point table.

    dᵢ = dᵢ₋₁ + √(Δx² + Δy²)

    Best route across the terrain route.js
    • CivilCraft
    64-bit
  • Sample stations

    The stations where sections are cut: every multiple of the step, both ends, the curve ends and any extra stations.

    sta = round₆(k × step) for whole k; neighbors closer than 1e-6 merged

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Sample line at a station

    The two ends of the line square to the alignment at a station.

    right = (sin dir, −cos dir); a = c − right × left; b = c + right × right offset

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Surface along a sample line

    The ground or design line along a sample line, with a point at every triangle edge it crosses.

    z at a + (b − a)·t for every edge-crossing parameter t; o = offA + (offB − offA)·t

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Segment crossing parameter

    Where one segment crosses another, as a fraction along the first.

    den = r × s; t = ((q − p) × s) ÷ den; u = ((q − p) × r) ÷ den

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Elevation of a section line at an offset

    The elevation of a section at any offset, between its points.

    z = z₀ + (z₁ − z₀)·(o − o₀) ÷ (o₁ − o₀)

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Cut and fill area of a section

    The area of cut and of fill between the ground line and the design line of one section.

    per interval: area = (e₀ + e₁) ÷ 2 × w; where the lines cross: o× = o₀ + w·e₀ ÷ (e₀ − e₁), two triangles

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Feature line crossings

    The offset and elevation where each corridor feature line crosses the sample line.

    o = −left + (left + right)·t; z = z_p + (z_q − z_p)·u

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Spans inside the graded regions

    The parts of a sample line that lie inside the graded regions, which is where the design counts.

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Volumes between sections

    Cut and fill volume between neighboring sections and the running totals.

    V = (A₁ + A₂) ÷ 2 × (sta₂ − sta₁); cumulative = Σ V

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Section table as CSV

    Writes station, areas, volumes and running totals to a CSV file.

    areas to 2 decimals; volumes to 1 decimal; feet projects: volume ÷ 27 (cubic yards)

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • US gallon in cubic feet

    The factor that turns gallons into cubic feet in feet projects.

    1 gal = 0.133680556 ft³

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Peaking factor

    The ratio of peak to average sanitary flow for a population.

    Harmon: 1 + 14 ÷ (4 + √P); Babbitt: 5 ÷ P^0.2; P in thousands; held between pfMin and pfMax

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Average flow from people

    People times per-person daily flow, in project flow units.

    m: P × L/day ÷ 1000 ÷ 86400; ft: P × gal/day × 0.133680556 ÷ 86400

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Infiltration flow

    Tributary area times the infiltration allowance, in project flow units.

    m: ha × L/s per ha ÷ 1000; ft: ac × gal/day per ac × 0.133680556 ÷ 86400

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Design flow, slope and velocity per pipe

    For each pipe in flow order: the people and area above it, the peak flow, the slope, the full capacity, the normal depth and the velocity.

    S = (inv up − inv down) ÷ length; Q = q_dom × pf + q_inf; ratio = Q ÷ Q_full; V = Q ÷ A(yn)

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Pipe size for the design flow

    The smallest listed pipe size whose allowed share of full capacity carries the design flow.

    first size with Q_full(size) × maxFull ≥ Q

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Catchment runoff hydrograph

    The runoff from one catchment at each time step for a constant storm.

    q(t) = k·C·A·(depth(t) − depth(t − w)) ÷ w; depth(τ) = i·clamp(τ, 0, duration); k = 1 ÷ 360 (m), 1 (ft)

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Muskingum coefficients

    The three weights of the routing equation for a reach.

    d = K(1 − X) + Δt ÷ 2; c₀ = (−KX + Δt ÷ 2) ÷ d; c₁ = (KX + Δt ÷ 2) ÷ d; c₂ = (K(1 − X) − Δt ÷ 2) ÷ d

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Routing one reach

    The outflow hydrograph of a pipe from its inflow hydrograph.

    O₂ = max(0, c₀·I₂ + c₁·I₁ + c₂·O₁) on a step of max(Δt, 2KX); values between steps by linear interpolation

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Travel time and weighting of each pipe

    The routing constants K and X of each pipe from its length, slope and rational peak flow.

    c = 1.5 × max(V, 0.1); K = L ÷ c ÷ 60; X = clamp(½(1 − Q ÷ (T·S·c·L)), 0, ½)

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Summing flows and reading peaks

    Adds the hydrographs arriving at each structure and reads each pipe's peak in, peak out, attenuation and share of capacity.

    att = max(0, 1 − peak out ÷ peak in); ratio = peak out ÷ capacity; over when peak out > capacity × (1 + 1e-9)

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Hydrograph as CSV

    Writes a structure's hydrograph as minutes and flow.

    minutes to 3 decimals; flow to 6 decimals

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Slope as typed

    Turns a typed slope (ratio, percent, degrees or vertical) into horizontal run per unit rise.

    percent: H = 100 ÷ p; degrees: H = 1 ÷ tan(a·π ÷ 180); ratio: H = h ÷ v

    Pad side slopes and retaining walls sides.js
    • CivilCraft
    64-bit
  • Wall height at each point

    The top, bottom and height of a retaining wall at each point along the pad edge.

    h = |z_pad − z_ground|; top = max; bottom = min

    Pad side slopes and retaining walls sides.js
    • CivilCraft
    64-bit
  • Wall length and face area

    The total length, face area, greatest height and average height of the walls.

    length = Σ l; face = Σ l·(h₁ + h₂) ÷ 2; average height = face ÷ length

    Pad side slopes and retaining walls sides.js
    • CivilCraft
    64-bit
  • Tall wall and steep slope checks

    Flags a wall higher than the limit and a cut or fill slope steeper than the limit.

    wall: h > limit + 1e-9; slope: H < max slope − 1e-9

    Pad side slopes and retaining walls sides.js
    • CivilCraft
    64-bit
  • Major contour test

    Decides whether a contour goes on the major layer and gets an elevation label.

    major when |z ÷ M − round(z ÷ M)| < 1e-6, M = interval × major count

    Plan drawing and section sheets for DXF and PDF scene.js
    • CivilCraft
    64-bit
  • Alignment curves as arcs

    Writes each curve of an alignment as an arc with its center, radius and start and end angles.

    a₁ = a₀ ± Δ; arc from a₀ to a₁ counterclockwise

    Plan drawing and section sheets for DXF and PDF scene.js
    • CivilCraft
    64-bit
  • Pipe line between structure walls

    Draws each pipe from the wall of one structure to the wall of the next.

    round: half = outside width ÷ 2; rectangle: half = min(L ÷ 2 ÷ |u·along|, W ÷ 2 ÷ |u·across|)

    Plan drawing and section sheets for DXF and PDF scene.js
    • CivilCraft
    64-bit
  • Scene to DXF entities

    Turns the scene's lines, arcs, points and labels into the entities the DXF writer takes.

    text height = paper mm ÷ (mm per model unit); middle-anchored text moved by height ÷ 2 across its direction

    Plan drawing and section sheets for DXF and PDF scene.js
    • CivilCraft
    64-bit
  • Section cell size and vertical exaggeration

    Sizes the cell every section is drawn in and picks the largest vertical exaggeration that fits the page.

    width = (left + right)·s + margins; height = 1.2 × largest relief × s × vex + margins; vex = the largest of 10, 5, 2, 1 not above the wanted one that fits

    Plan drawing and section sheets for DXF and PDF section-sheets.js
    • CivilCraft
    64-bit
  • Vertical scale label

    The vertical scale printed in the title strip of a section sheet.

    m: 1 : round(1000 ÷ sv); ft: 1 inch = (25.4 ÷ sv) feet, to 1 decimal

    Plan drawing and section sheets for DXF and PDF section-sheets.js
    • CivilCraft
    64-bit
  • Section points on paper

    Places each section's ground and design points, grid lines and labels in its cell.

    X = x₀ + (o + left)·s; Y = y₀ + (z − z₀)·sv; z₀ = floor((z_mid − span ÷ 2) ÷ step)·step

    Plan drawing and section sheets for DXF and PDF section-sheets.js
    • CivilCraft
    64-bit
  • Meters per unit for units found in files

    The factor for each linear unit name a LandXML file can carry.

    US survey foot = 1200 ÷ 3937 m; foot = 0.3048 m

    Typed lengths, stations and unit text units.js
    • CivilCraft
    Exact
  • One typed length

    Reads one length as typed (plain number, feet and inches, fraction, mm, cm or m) into project units.

    feet + inches ÷ 12; meter project: feet × 12 × 0.0254; feet project, metric mark: meters ÷ 0.0254 ÷ 12

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Station text

    Writes a station as text, such as 12+34.56 in feet or 1+234.567 in meters.

    r = round(|sta|, decimals); whole = floor(r ÷ station length + 1e-9); rest = r − whole × station length

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Station as typed

    Reads a station typed as 12+34.56 or as a plain number.

    value = whole × station length + rest

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Volume text

    Writes a volume in cubic yards or cubic meters, or in the volume unit chosen in Settings.

    feet: V ÷ 27 cu yd; chosen unit: V × (m per unit)³ through the shared unit table

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Area text

    Writes an area in square feet or square meters, or in the area unit chosen in Settings.

    chosen unit: A × (m per unit)² through the shared unit table

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Bearing text

    Writes a direction as a quadrant bearing in degrees, minutes and seconds.

    azimuth = (90 − a·180 ÷ π) mod 360; quadrant angle to whole seconds

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Degrees, minutes, seconds

    Splits an angle in degrees into whole degrees, minutes and seconds.

    s = round(|deg| × 3600); d = floor(s ÷ 3600); m = floor(rest ÷ 60)

    Typed lengths, stations and unit text units.js
    • CivilCraft
    64-bit
  • Search box around a point

    The longitude and latitude box that holds a radius in meters around a point.

    Δlat = r ÷ 111320; Δlon = r ÷ (111320 × max(0.01, cos lat))

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Ring area

    The signed area of one polygon ring.

    A = ½ Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    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.