Functional Weave
Code in Rust

construction.concrete-volume@1.0.0

README.md

1,923 bytes · view raw

# construction.concrete-volume

How much concrete a set of pours needs, and how much to order from the
ready-mix plant. Each element is a slab, strip footing or pad (a rectangular
box: length × width × depth) or a round column (π d² / 4 × height), with a
count for identical ones.

## How it is worked out

1. Every dimension, given in metres, is taken to the nearest millimetre.
2. A rectangular element is an exact integer of cubic millimetres. A column
   is `π × d × d / 4 × h` in floating point, evaluated in that order in every
   language and rounded to a whole cubic millimetre (`math.round-float`).
   Then times the count.
3. `elementCubicMetres` and `cubicMetres` are those, and their total, to the
   nearest litre (half up), shown in m³ to 3 decimal places. The total is
   rounded once, not summed from the rounded elements.
4. The order: the total rounded **up** to a whole litre, plus wastage, then
   **up** to the next 0.1 m³, the smallest step most plants sell in.

Working in metres and rounding the float up is the naive way and orders too
much: 3 × 1 × 0.1 is 0.30000000000000004 in floating point, which a ceiling to
the tenth turns into 0.4 m³.

## What it does not do

It does not add wastage for you (typically 5-10% for foundations poured into
trenches, less for formed slabs; that is the caller's call), deduct
reinforcement, work out the trench volume for an uneven formation, or know a
plant's minimum load. Other shapes (a stepped footing, a ramp) are several
rectangular elements.

Limits: each dimension more than 0 and at most 1000 m, and at least 1 mm after
rounding; count 1 or more; wastage 0 to 10,000 basis points; the total at most
2^53 − 1 mm³ (about 9 million m³), beyond which JavaScript integers stop being
exact and the calculation is refused. A slab, footing or pad needs length,
width and depth; a column needs diameter and height; other fields are
ignored.