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

  • Polygon area in square meters

    The area of a polygon with holes, scaled to square meters.

    A = (Σ |outer ring| − Σ |holes|) × kx × ky

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Meters per degree at the site

    The factors that turn longitude and latitude differences into meters, and the search window.

    kx = 111320 × cos(lat); ky = 111320

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

    The distance from the point to each building and the building's footprint area.

    d = √(((cx − x)·kx)² + ((cy − y)·ky)²), c = center of the building's bounding box

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Shares of the parcel by sampling

    The share of the parcel that lies in each zoning district, soil unit and flood zone.

    share = points in the zone ÷ points in the parcel, on a 40 × 40 grid over the parcel's bounding box

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Ground mesh with elevation bands

    The triangles, normals and colors of a ground surface, cut at the elevation band levels.

    position = (x + dx, y + dy, (z − origin z) × exaggeration); normal = normalized sum of face normals

    3D site view scene site3d.js
    • CivilCraft
    32-bit, display only
  • Map picture coordinates on the ground

    Where each ground vertex falls in the map picture draped over it.

    u = (x + origin x − min x) ÷ width; v = (y + origin y − min y) ÷ height

    3D site view scene site3d.js
    • CivilCraft
    32-bit, display only
  • Road body mesh

    The lanes, shoulders, curbs and walks of a corridor as triangles between neighboring sections.

    3D site view scene site3d-landscape.js
    • CivilCraft
    32-bit, display only
  • Rail mesh

    Each rail as a swept I-shaped outline along the track's sections.

    3D site view scene site3d-rail.js
    • CivilCraft
    32-bit, display only
  • Local origin of the 3D scene

    The project point every 3D position is measured from.

    x, y = the ground surface's own origin; z = floor(lowest elevation)

    3D site export (GLB, OBJ, USD) and the 3D pointer readout site3d.js
    • CivilCraft
    64-bit
  • Point under the pointer in 3D

    The object under the pointer and the project coordinates of the hit, shown in the 3D view's tooltip.

    X = x + origin x; Y = y + origin y; Z = z ÷ exaggeration + origin z

    3D site export (GLB, OBJ, USD) and the 3D pointer readout site3d.js
    • CivilCraft
    32-bit in part
  • Tooltip coordinates in the 3D view

    The name of the object under the pointer with its easting, northing and elevation.

    E, N, Z to 2 decimals

    3D site export (GLB, OBJ, USD) and the 3D pointer readout site-view3d.js
    • CivilCraft
    32-bit in part
  • Scene positions to meters, Y up

    Turns the scene's local positions into the coordinates written to GLB and OBJ files.

    x′ = x·k; y′ = (z ÷ exaggeration)·k; z′ = −y·k; k = 1200 ÷ 3937 (US survey feet) or 1

    3D site export (GLB, OBJ, USD) and the 3D pointer readout site3d-export.js
    • CivilCraft
    32-bit in part
  • GLB position bounds

    The smallest and largest coordinate of each mesh, which a GLB file must state.

    min, max over the vertices, each passed through Math.fround

    3D site export (GLB, OBJ, USD) and the 3D pointer readout site3d-export.js
    • CivilCraft
    32-bit in part
  • OBJ vertex text

    Writes the vertices, normals, faces, lines and points of the site as OBJ text.

    v x y z with 4 decimals (meters); vn with 5 decimals

    3D site export (GLB, OBJ, USD) and the 3D pointer readout site3d-export.js
    • CivilCraft
    32-bit in part
  • USD points and the Site transform

    Writes the site's meshes, lines and survey points to USD in meters, with the Site's transform putting them at the project coordinates.

    point = (x·k, y·k, (z ÷ exaggeration)·k) as 32-bit; Site translation = origin × k as doubles

    3D site export (GLB, OBJ, USD) and the 3D pointer readout usd-civilcraft.js
    • CivilCraft
    32-bit in part
  • Ground slope under a table

    The slope of the ground under one table, from a plane fitted through its sample points.

    least squares z = a + b·x + c·y on centered points; b = (Sxz·Syy − Syz·Sxy) ÷ d, c = (Syz·Sxx − Sxz·Sxy) ÷ d, d = Sxx·Syy − Sxy²

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Table size and the shadow rule

    The width, slant length, plan depth and height of one table, and how fast the winter shadow drops behind a row.

    D = Ls·cos β; H = Ls·sin β; shadow drop per meter = tan(α) ÷ max(0.2, cos Δ)

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • One table on its piles

    Tests a table position: inside the region, off kept-out ground, not too steep, and how high its lower edge must stand.

    z₀ = max over samples of (z_ground − dq·tan β + clearance); pile = z₀ − z_ground at the lower edge; slope = atan(|gradient|)

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Row spacing on the ground

    Steps back from each placed table to the first position where its shadow no longer reaches the next table's lower edge.

    accept when q ≥ q_top + 0.02 and z₀ ≥ z_top − (q − q_top)·tanE − 1e-6; otherwise q += step

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Module count and installed power

    The number of modules and the installed power of the array.

    modules = tables × per row × stacked; kWp = round(modules × Wp ÷ 10) ÷ 100

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Terrain horizon

    The highest angle of the terrain seen from a point, in each 5 degrees of bearing.

    elevation angle = max over d of atan2(z(d) − (z₀ + observer height), d)

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Hours hidden by the horizon

    Marks the hours of the year when the sun is below the terrain horizon as fully shaded before the yield is computed.

    shaded when sun altitude < horizon elevation at round(azimuth ÷ 5) × 5 degrees

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Sun directions through a day

    The direction to the sun at the middle of each time step of a local day, and the hours it is above the horizon.

    minute = (k + 0.5) × step; day length = samples above the horizon × step ÷ 60

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    64-bit
  • Terrain raster for shadows

    The ground elevations on a square grid, used to test whether the ground blocks the sun.

    z[i, j] = elevation at (minX + i·cell, minY + j·cell)

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    32-bit in part
  • Ray against a building mass

    Whether the ray from a point toward the sun passes through a mass.

    t range from the mass's bottom and top; slab test on the footprint box; crossings of the sun's line with each footprint edge, inside between every other pair

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    64-bit
  • Ray against the ground

    Whether a point sees the sun: no mass in the way and no ground rising above the ray.

    march one cell at a time: x += dx, y += dy, z += rise; blocked when ground > z + 0.001

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    64-bit
  • Hours of sun per ground cell and wall point

    Adds one time step to every ground cell and wall point that is lit at each sun sample, then averages over the days.

    hours += step for each lit sample; mean = hours ÷ days; max = largest ground mean

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    32-bit in part
  • Mean hours per floor and per wall

    The mean hours of sun on each floor of each wall and on the wall as a whole.

    floor mean = Σ point hours ÷ points; wall mean = Σ floor means ÷ floors

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    64-bit
  • Combining runs over different days

    Joins the results of several runs of the same site into one, weighting each by its number of days.

    hours = Σ (hoursᵢ × daysᵢ) ÷ Σ daysᵢ

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    32-bit in part
  • Ground hours as CSV

    Writes each ground cell's center and its hours of sun a day.

    x, y to 3 decimals; hours to 2 decimals

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    32-bit in part
  • Wall hours as CSV

    Writes each wall's facing direction and the hours of sun a day on each floor.

    facing = round((90 − normal·180 ÷ π) mod 360); hours to 2 decimals

    Hours of direct sun on the ground and on walls sunhours.js
    • CivilCraft
    64-bit
  • Turn angle at a point

    The signed turn of the line at a point of intersection.

    Δ = atan2 of the leg after − atan2 of the leg before, wrapped to (−π, π]

    Why a curve does not fit, and the radius or length that would solve-why.js
    • CivilCraft
    64-bit
  • Tangent length of each curve

    The turn and the tangent length each curve takes on either side of its point.

    T = r × tan(|Δ| ÷ 2)

    Why a curve does not fit, and the radius or length that would solve-why.js
    • CivilCraft
    64-bit
  • Largest radius that fits

    The largest radius at a point that fits between its neighbors' curves as they are.

    room = min(d_before − T_before, d_after − T_after); r_max = room ÷ tan(|Δ| ÷ 2)

    Why a curve does not fit, and the radius or length that would solve-why.js
    • CivilCraft
    64-bit
  • Overlapping curves and the fixes offered

    Finds neighboring curves whose tangents overlap and offers radii that fit.

    overlap when Tₐ + T_b > L + 1e-9; both scaled by f = L ÷ (Tₐ + T_b); offered radius = floor(r × 100 + 1e-9) ÷ 100

    Why a curve does not fit, and the radius or length that would solve-why.js
    • CivilCraft
    64-bit
  • Vertical curves that do not fit

    Finds vertical curves longer than the room between their neighbors and offers the longest length that fits.

    A = (g₂ − g₁) × 100; L = K × |A| when given by K; room = 2 × min(back, forward); offered L = floor(room × 100 + 1e-9) ÷ 100; K = L ÷ |A|

    Why a curve does not fit, and the radius or length that would solve-why.js
    • CivilCraft
    64-bit
  • Stations to stake

    Every multiple of the step between two stations, both ends, and the alignment's own curve points in between.

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

    Staking reports staking.js
    • CivilCraft
    64-bit
  • Stake position

    The coordinates of a stake at a station and an offset to the right or left.

    x = xₚ + off × sin(dir); y = yₚ − off × cos(dir)

    Staking reports staking.js
    • CivilCraft
    64-bit
  • Stake rows with cut or fill

    One row per station and offset with design elevation, ground elevation and cut or fill.

    cf = ground − design (positive = cut)

    Staking reports staking.js
    • CivilCraft
    64-bit
  • Survey points against the alignment

    Each survey point's station and offset on the alignment, the design there and the cut or fill to the point's own elevation.

    cf = point elevation − design

    Staking reports staking.js
    • CivilCraft
    64-bit
  • Staking table as CSV

    Writes the stake rows to a CSV file.

    northing, easting, design, ground and cut or fill to 3 decimals; offset and the C/F column to 2 decimals

    Staking reports staking.js
    • CivilCraft
    64-bit
  • Millimeters per project unit

    The factor from project feet or meters to millimeters.

    m: 1000; ft: 1,200,000 ÷ 3937 (US survey foot)

    Drainage structure types and their library items structs.js
    • CivilCraft
    Exact
  • Inside and outside size of a structure

    The inside and outside width and length, the wall and the frame of a structure in project units.

    inside = size ÷ P; outside = inside + 2 × wall ÷ P; P = 12 (inches per foot) or 1000 (mm per m)

    Drainage structure types and their library items structs.js
    • CivilCraft
    64-bit
  • Plan shapes of a type

    The outside wall, inside wall and frame opening of a type as plan shapes in millimeters.

    r = round₆((size × M) ÷ 2); M = 25.4 (inch) or 1 (mm)

    Drainage structure types and their library items structs.js
    • CivilCraft
    64-bit
  • Round outline as a polygon

    The outline of a round structure's body as points on a circle.

    pᵢ = (r·cos(2π·i ÷ n), r·sin(2π·i ÷ n)), n = 48

    Drainage structure types and their library items structs.js
    • CivilCraft
    64-bit
  • Library item of a type

    The library item for a type: its body from the underside of the floor slab to the rim, its sizes, and every parameter in millimeters.

    H = depth × U + base × M; body = outline from −H to 0; parameters as text of (value × factor)

    Drainage structure types and their library items structs.js
    • CivilCraft
    64-bit
  • Type read back from a library item

    Turns a library item's millimeter parameters back into a type in the project's units.

    value = millimeters ÷ M (sizes) or ÷ U (sump, depth)

    Drainage structure types and their library items structs.js
    • CivilCraft
    64-bit
  • Follower behind a leader (tractrix)

    Where a rear axle ends up when the point that pulls it moves along a straight piece.

    α₁ = 2·atan(tan(α₀ ÷ 2) × e^(−d ÷ L)); follower = B + L × (−w turned by α₁)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Steady-state turning radii

    The radius each rear axle and hitch runs on when the front axle follows a circle for ever.

    r = √(max(0, R² − L²)); hitch = √(r² + c²)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Stepping along the path

    Cuts the path into steps no longer than the step length, with a point and travel direction on every line and arc.

    step = max(0.001, shortest wheelbase ÷ 40); k = ceil(L ÷ step); s = s₀ + L·j ÷ k

    Vehicle swept paths swept.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.