# construction.roof-pitch The pitch of a roof, the length of one rafter and the area of the roof slopes, from the span, the rise and the length along the ridge. All dimensions are in metres. - **duo** (a pitched roof with a ridge in the middle): the run of each rafter is half the span, and there are two slopes. - **mono** (a lean-to or mono-pitch): the run is the whole span, and there is one slope. The pitch is `atan(rise / run)` in degrees, the rafter is `sqrt(run² + rise²)`, and the area is rafter × roof length × slopes. ## Rounding The pitch is rounded to 2 decimal places, the rafter to 3 (the nearest millimetre) and the area to 2, each with `math.round-float`, half away from zero. The area is worked from the **unrounded** rafter: on a 7.2 m span with a 2.4 m rise and a 20 m ridge the rafter is 4.32666 m, so the area is 173.07 m², while 4.327 × 40 would give 173.08. ## Why every language agrees The angle comes from `math.atan` (fdlibm's arctangent from + − × ÷ only), not `Math.atan`, whose last bit differs between platforms. The square root is the platform's own: IEEE 754 requires square root to be correctly rounded, like + − × ÷, so it is the same double everywhere (`geo.distance` relies on the same guarantee). Degrees are radians × 57.29577951308232, 180/π as a double, written out. ## What it does not do - Overhangs (eaves and verges), ridge and fascia boards, and the rafter's plumb cuts: the rafter length is plate to ridge along the slope, and the area is the slope over the building's footprint. Add overhang to the run and roof length yourself for tiling or felt quantities, then add waste. - Hips, valleys and unequal pitches. A hipped roof's slope area does equal plan area ÷ cos(pitch) when every slope has the same pitch, but its rafters do not; that is a different calculation. - Pitch from a known angle (the reverse); rise = run × tan(pitch). A rise of 0 is allowed (a flat roof: pitch 0, rafter equal to the run). Span and roof length must be above zero, and every dimension at most 10,000 m.