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

  • Convert between two units

    A value in one unit as a value in another unit of the same kind.

    result = v × (n₁ × d₂) ÷ (d₁ × n₂)

    Unit conversion unit-table.js Every app
    Exact
  • Typed text to a unit

    What was typed, with its unit, as a value in the unit the field wants.

    3 yd typed into a feet field = convert(3, yd, ft) = 9

    Unit conversion unit-table.js Every app
    Exact
  • A value to the base unit

    A number in any unit as meters, square meters, cubic meters, radians or rise over run.

    base = v × n ÷ d (v × π × n ÷ d for degrees and gons)

    Unit conversion unit-table.js Every app
    64-bit
  • A base value to a unit

    A stored base value as a number in the unit shown.

    value = base × d ÷ n (base ÷ π × d ÷ n for degrees and gons)

    Unit conversion unit-table.js Every app
    64-bit
  • Which side of an edge

    Whether three points turn counter-clockwise, clockwise, or lie on one line.

    sign of (b − a) × (c − a)

    Surface triangulation tin.js
    • BimCraft
    • CivilCraft
    Exact
  • Is an edge Delaunay

    Whether the point across an edge lies inside the circle through the triangle on this side.

    sign of the in-circle determinant of a, b, c, d

    Surface triangulation tin.js
    • BimCraft
    • CivilCraft
    Exact
  • Triangle under a point

    The triangle a point falls in and its three barycentric weights.

    w₁ = ((y_b − y_c)(x − x_c) + (x_c − x_b)(y − y_c)) ÷ d, w₃ = 1 − w₁ − w₂

    Surface triangulation tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Elevation at a point

    The surface elevation at an easting and northing.

    z = w₁·z₁ + w₂·z₂ + w₃·z₃

    Surface triangulation tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Slope of a triangle

    Rise over run and the downhill direction of one triangle.

    n = u × v; slope = √((n_x ÷ n_z)² + (n_y ÷ n_z)²)

    Surface triangulation tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Plan and surface area

    The surface's area in plan and along the slope, with its elevation range.

    area in plan = Σ |n_z| ÷ 2; surface area = Σ |u × v| ÷ 2

    Surface triangulation tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Add, subtract, multiply, divide

    The four operations on values that carry units.

    a + b and a − b need the same dimensions; a × b and a ÷ b combine them

    Calc sheets calc.js Every app
    64-bit
  • Comparisons

    Pass or fail checks such as M <= 40 kN m.

    a ≤ b is true when a ≤ b + 1e-12 × max(1, |a|, |b|)

    Calc sheets calc.js Every app
    64-bit
  • Number shown

    A result as text in the sheet.

    6 significant digits; exponent form from 1e9 up and below 1e-4

    Calc sheets calc.js Every app
    64-bit
  • Reproject points

    Every point of a file from one coordinate system to another.

    (x, y) in the source system → (x, y) in the target system, point by point

    Map coordinate reprojection reproject-batch.js
    • BimCraft
    • CivilCraft
    64-bit
  • Map origin from latitude and longitude

    Eastings and northings of a typed latitude and longitude.

    (lon, lat) → (E, N), rounded to 0.000001 of the map unit

    Map coordinate reprojection crs-georef.js
    • BimCraft
    • CivilCraft
    64-bit
  • Model to map conversion

    Where a model sits on the map: origin, rotation and scale.

    X axis = (cos a, sin a) rounded to 1e-12; scale = model unit ÷ map unit

    Map coordinate reprojection crs-georef.js
    • BimCraft
    • CivilCraft
    64-bit
  • Normal of a tilted plane

    The unit normal of a plane from its tilt and compass bearing.

    n = (h_x·sin β, h_y·sin β, cos β), h = north·cos az + east·sin az

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Tilt and azimuth of a normal

    The tilt from horizontal and the compass bearing a plane faces.

    tilt = acos(clamp(n_z, −1, 1)); azimuth = (atan2(n·east, n·north) + 360) mod 360

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Axes of a plane from its normal

    The along-eave and up-slope directions of a roof face.

    u = (−n_y, nₓ, 0) ÷ √(nₓ² + n_y²); v = n × u

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Roof faces from triangles

    Groups upward triangles into planes and gives each plane's normal, tilt, azimuth, area and centroid.

    n = (B − A) × (C − A) ÷ |…|; area = |…| ÷ 2; face normal = unit(Σ area·n); centroid = Σ area·mid ÷ Σ area

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Point inside the face's triangles

    Tests whether a point in the face's own axes lies in any of its triangles.

    barycentric l₁, l₂, l₃ ≥ −eps ÷ √|d|

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Modules fitted in a roof face

    The positions and corners of the modules that fit inside a face with a setback.

    position = (s₀ + col × (across + gap), t₀ + row × (along + gap)); corner = centroid + s·u + t·v

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Row spacing without winter shade

    The distance between ground rows that leaves no shade at the winter solstice.

    h = slant × sin β; shadow = h ÷ tan α × max(0, cos Δaz); pitch = slant × cos β + shadow

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Ground rows of tables

    The tables and modules of a ground array with their corners, the pitch and the ground cover ratio.

    table width = n × across + (n − 1) × gap; row origin = origin − facing × pitch × r; GCR = slant ÷ pitch

    Solar array layout on roofs and ground pv.js
    • BimCraft
    • CivilCraft
    64-bit
  • Compass frame of the site

    The north and east unit vectors in the model's plan.

    north = n ÷ |n|; east = (north_y, −northₓ)

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Clock hour for a solar hour

    The clock time at which the sun's time is a given hour.

    clock = solar − (equation of time + 4 × longitude − 60 × time zone) ÷ 60

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Sun direction in model axes

    The sun's altitude, azimuth and direction for a solar hour, turned to the model's north.

    dir = east × dₓ + north × d_y, with d_z unchanged; ω = 15° × (solar hour − 12)

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Daily extraterrestrial radiation

    The energy on a horizontal plane above the atmosphere in one day.

    δ = 23.45° × sin(2π(284 + n) ÷ 365); ω_s = acos(−tan φ · tan δ); H₀ = 24 ÷ π × G_on ÷ 1000 × (cos φ cos δ sin ω_s + ω_s sin φ sin δ)

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Monthly diffuse fraction

    The share of a month's daily light that is diffuse, from the clearness index.

    ω_s ≤ 81.4°: 1.391 − 3.56 k + 4.189 k² − 2.137 k³; else 1.311 − 3.022 k + 3.427 k² − 1.821 k³

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Hourly share of the day's light

    The share of a day's total and diffuse light that falls in one hour.

    r_d = π ÷ 24 × (cos ω − cos ω_s) ÷ (sin ω_s − ω_s cos ω_s); r_t = (a + b cos ω) × r_d

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Hourly light from a typed monthly total

    Spreads a typed daily total over the hours and splits it into diffuse and direct light.

    I = H × r_t ÷ Σ r_t; I_d = min(I, H_d × r_d ÷ Σ r_d); DNI = min((GHI − DHI) ÷ cos z, 0.8 × G_on)

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Light on a tilted plane

    The direct, sky and ground-reflected light on a module plane in one hour.

    beam = DNI × cos θ; sky = DHI × (1 + cos β) ÷ 2; ground = GHI × ρ × (1 − cos β) ÷ 2; IAM = max(0, 1 − b₀(1 ÷ cos θ − 1))

    Sun position and light on a tilted plane for solar pv-sun.js
    • BimCraft
    • CivilCraft
    64-bit
  • Grid position from GeoTIFF tags

    The transform from cell column and row to map coordinates.

    x₀ = tie_X − tie_I × scale_X; y₀ = tie_Y + tie_J × scale_Y; pixel-is-point: x₀ −= ½(a + b), y₀ −= ½(d + e)

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • Cell size

    The single cell size of a square, north-up grid.

    cell = a when b = d = 0 and |a + e| < 1e-9 × |a|

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • ASCII grid header

    The size, cell size and lower-left corner of an ASCII grid.

    corner = center − cell ÷ 2 when the header gives cell centers

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • ASCII grid position

    The transform of an ASCII grid, with its origin at the top-left corner.

    top = yll + rows × dy

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • Elevation from a stored sample

    Turns one stored sample into an elevation, or into no value.

    z = v × scale + offset

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • Reading a window of cells

    Reads part of the grid, optionally every step-th cell, into an array of elevations.

    columns = ceil((c₁ − c₀) ÷ step); rows = ceil((r₁ − r₀) ÷ step)

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • Lowest and highest elevation

    The minimum and maximum elevation shown for a grid.

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • Position of a georeferenced picture

    The transform and bounding box of a picture read at a reduced size.

    sₓ = width ÷ w, s_y = height ÷ h; affine = [x₀, a·sₓ, b·s_y, y₀, d·sₓ, e·s_y]

    Elevation grids read from GeoTIFF and ASCII files raster.js
    • BimCraft
    • CivilCraft
    64-bit
  • Longitude and latitude to local meters

    The position of a point in meters east and north of the address point.

    x = (lon − lon₀) × 111320 × cos(lat₀); y = (lat − lat₀) × 111320

    Site surroundings in local meters site-context.js
    • BimCraft
    • ModelCraft
    • CivilCraft
    64-bit
  • Local meters back to longitude and latitude

    The longitude and latitude of a local point.

    lon = lon₀ + x ÷ (111320 × cos(lat₀)); lat = lat₀ + y ÷ 111320

    Site surroundings in local meters site-context.js
    • BimCraft
    • ModelCraft
    • CivilCraft
    64-bit
  • Outlines and heights kept in the site file

    Converts each outline to local meters, thins and rounds it, and sets the item's height.

    ring = round(x × 100) ÷ 100, round(y × 100) ÷ 100; height = source height, else levels × 3

    Site surroundings in local meters site-context.js
    • BimCraft
    • ModelCraft
    • CivilCraft
    64-bit
  • Thinning a long outline

    Reduces an outline of more than 400 points by keeping every n-th point.

    step = ⌈points ÷ 400⌉; keep indexes divisible by step

    Site surroundings in local meters site-context.js
    • BimCraft
    • ModelCraft
    • CivilCraft
    64-bit
  • Local origin and merging of points

    Moves every point to a local origin and makes points that fall on the same spot one vertex.

    origin = ⌊min x⌋, ⌊min y⌋; key = round(x ÷ 1e-4), round(y ÷ 1e-4)

    Ground surface triangulation and contours tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Coordinates handed to the triangulator

    Packs the local coordinates for Delaunator and runs the Delaunay triangulation.

    coords = (x, −y) per vertex

    Ground surface triangulation and contours tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Boundary clipped to the data and given elevations

    Clips the outer boundary to the convex hull of the data and takes each corner's elevation from a first surface built without it.

    z_corner = elevationAt(x, y) with a 1e-6 edge tolerance

    Ground surface triangulation and contours tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Triangles kept inside the boundary

    Drops the triangles whose center lies outside the boundary.

    keep when the centroid (Σx ÷ 3, Σy ÷ 3) is inside the boundary polygon

    Ground surface triangulation and contours tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Surface from given triangles

    Builds a surface from vertices and faces read from a file, keeping every triangle counter-clockwise.

    o = (x_b − x_a)(y_c − y_a) − (y_b − y_a)(x_c − x_a); swap b, c when o < 0

    Ground surface triangulation and contours tin.js
    • BimCraft
    • CivilCraft
    64-bit
  • Crossing of two breakline segments

    Finds where two segments properly cross, as a fraction along each.

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

    Ground surface triangulation and contours tin.js
    • BimCraft
    • 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.