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

  • Turning a picture

    The new angle after a turn about the picture's center.

    angle′ = r6(((angle + deg) mod 360 + 360) mod 360)

    Picture backgrounds: scale, placement and print picture.js
    • BimCraft
    64-bit
  • Fit in a box

    Centers an unscaled picture in the view at 90 % of the box.

    k = min(box width ÷ w, box height ÷ h) × 0.9

    Picture backgrounds: scale, placement and print picture.js
    • BimCraft
    64-bit
  • Corners in 3D

    The picture's corners in level coordinates, for a level or a vertical plane.

    p = origin + u·û + v·v̂

    Picture backgrounds: scale, placement and print picture.js
    • BimCraft
    64-bit
  • Vertical picture in an elevation or section

    Decides whether a standing picture shows in a view and gives its matrix there.

    shown when |û·dir| ≤ sin(2°) and, in a section, |(a − o)·dir| ≤ 100 mm; x = a·right ± picture x, y = level difference + picture y

    Picture backgrounds: scale, placement and print picture-sheet.js
    • BimCraft
    64-bit
  • Number format for picture matrices

    Turns a matrix entry or opacity into the text written in the PDF.

    toFixed(6), trailing zeros removed; |v| < 5e-7 → 0

    Picture backgrounds: scale, placement and print picture-pdf.js
    • BimCraft
    64-bit
  • Pixels to print a picture at

    The pixel size a picture is drawn at on a sheet, limited by dots per inch and total pixels.

    paper mm per pixel = scale ÷ ratio; dpi = 25.4 ÷ that; k = min(1, max dpi ÷ dpi, √(max pixels ÷ (w·h)))

    Picture backgrounds: scale, placement and print picture-pdf.js
    • BimCraft
    64-bit
  • Matrix for the image's unit square

    Turns the pixel-to-plan matrix into the one PDF needs for an image drawn on a unit square.

    [a·w, b·w, −c·h, −d·h, e + c·h, f + d·h]

    Picture backgrounds: scale, placement and print picture-pdf.js
    • BimCraft
    64-bit
  • Scale from two points and a distance

    How many millimeters one page unit is, from two picked points and the true distance between them.

    scale = distance in mm ÷ √(Δx² + Δy²)

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Circle through three points

    The center and radius of the circle through three points.

    d = 2(p_x(q_y − r_y) + q_x(r_y − p_y) + r_x(p_y − q_y)); center from the squared lengths ÷ d

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Arc from a Bézier curve

    Recognizes a cubic curve that is a circular arc and gives its center, radius, start angle and sweep.

    circle through P(0), P(0.5), P(1); accepted when |dist(P(t), center) − r| ≤ 0.012 r at t = 0.25 and 0.75

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Page lines and arcs in millimeters

    Scales a PDF page's line segments and arcs to millimeters and finds their bounds.

    x_mm = x_pt × mm per point

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Scan lines and arcs in millimeters

    Scales a traced scan from pixels to millimeters and turns its y axis up.

    x = px × k; y = (height in px − py) × k

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Joining lines cut at a tee

    Merges lines of one straight run that are split by a joining wall.

    merged when |cos angle| ≥ cos 1.2°, both ends within 35 mm of the first line, and the gap ≤ 350 mm

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Hatching detection

    Finds bundles of short parallel lines so they are not taken for walls.

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Merged wall line and thickness

    The center line and thickness of a wall made of collinear pieces with openings between them.

    t = Σ tᵢ·Lᵢ ÷ Σ Lᵢ; offset = Σ offsetᵢ·Lᵢ ÷ Σ Lᵢ; A, B = base + u·s + n·offset

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Squaring a scanned page

    Decides whether a scan is turned back before it is traced.

    turned by the found angle when |angle| > 0.15° and confidence > 1.6

    Walls and openings from PDF pages and scans plan-pages.js
    • BimCraft
    64-bit
  • Stored position and angle

    The X, Y and Angle written for a symbol.

    X, Y = round(mm ÷ unit, 6); Angle = round(radians × 180 ÷ π, 4)

    Plan symbol positions plan-symbols.js
    • BimCraft
    64-bit
  • Point on a wall face

    The point on a wall's face at a distance along the wall, and the direction the face looks.

    at = a + s·u + side × (t ÷ 2)·n; face angle = atan2(side·n_y, side·nₓ)

    Plan symbol positions plan-symbols.js
    • BimCraft
    64-bit
  • Symbols following a wall

    Moves a symbol to where its stored side and distance are on the wall now.

    turn = atan2(sin Δ, cos Δ), Δ = new face angle − stored face angle

    Plan symbol positions plan-symbols.js
    • BimCraft
    64-bit
  • Program totals

    The net and gross floor area and the number of rooms in the program.

    net = Σ count × area; gross = net ÷ efficiency

    Massing options from a room program program-mass.js
    • BimCraft
    64-bit
  • Rectangle inside the envelope

    Tests whether a turned rectangle lies inside the envelope.

    Massing options from a room program program-mass.js
    • BimCraft
    64-bit
  • Rectangle of a wanted area

    The rectangle of a given proportion and area nearest the middle of the envelope.

    short = √(area ÷ ratio); long = short × ratio

    Massing options from a room program program-mass.js
    • BimCraft
    64-bit
  • L and U shapes of a wanted area

    An L-shaped or U-shaped footprint scaled to the wanted area and placed in the envelope.

    k = √(wanted area ÷ template area)

    Massing options from a room program program-mass.js
    • BimCraft
    64-bit
  • Rooms stacked on floors

    Assigns rooms to floors up to each floor's usable area.

    placed when floor net + room area ≤ usable area + 1e-6

    Massing options from a room program program-mass.js
    • BimCraft
    64-bit
  • Areas reported for an option

    Footprint, gross area, required area, surplus and coverage of one massing option.

    footprint = |shoelace|; gross = footprint × floors ÷ 10⁶; surplus = gross − required; coverage = footprint ÷ envelope area

    Massing options from a room program program-mass.js
    • BimCraft
    64-bit
  • Option handed to the site study

    The option's points and floor height in the project's units.

    x = mm × unit per mm

    Massing options from a room program program-mass.js
    • BimCraft
    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
  • Site position and time zone

    The latitude, longitude, north direction and time zone used for the sun.

    time zone = round(longitude ÷ 15) unless given

    Solar arrays on the model pv-calc.js
    • BimCraft
    64-bit
  • Model triangles in millimeters

    Every placed triangle of the model that can shade or carry modules.

    mm = mesh position × unit in mm

    Solar arrays on the model pv-calc.js
    • BimCraft
    32-bit in part
  • Array tilt and power

    The tilt, azimuth and peak power recorded for a planned array.

    tilt = acos(clamp(n_z, −1, 1)) × 180 ÷ π; kWp = modules × Wp ÷ 1000

    Solar arrays on the model pv-calc.js
    • BimCraft
    64-bit
  • Array definition stored in the file

    The text that records an array's plane, module size and module centers.

    normal, u, v: round to 1e-6; module centers and table corners: round to 0.1 mm

    Solar arrays on the model pv-calc.js
    • BimCraft
    64-bit
  • Arrays read back from the file

    Rebuilds each array's modules and corners from its stored definition.

    corner = c ± u × across ÷ 2 ± v × along ÷ 2

    Solar arrays on the model pv-calc.js
    • BimCraft
    64-bit
  • Module frames in the level's axes

    Turns module centers and the array's directions from model axes into the level's own axes for the stored solids.

    point′ = S⁻¹ · p; direction′ = S⁻¹ · d − S⁻¹ · 0

    Solar arrays on the model pv-calc.js
    • BimCraft
    64-bit
  • Shade fraction of an array

    The shaded share of each array for every month and hour.

    fraction = Σ (table fraction × table samples) ÷ Σ samples

    Solar arrays on the model pv-calc.js
    • BimCraft
    64-bit
  • Overcurrent device size

    The smallest standard device that is at least the required current.

    smallest x in the list with x ≥ amps − 1e-9

    Solar one-line currents, devices and wires pv-oneline.js
    • BimCraft
    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.