{
 "schema": 1,
 "id": "roof-pitch-and-slope",
 "title": "Roof pitch, slope and diagonals",
 "description": "Pitch to angle, grade per cent, slope angle, common rafter length and the diagonal that squares a layout, with the calculators' pinned vectors.",
 "url": "https://craftquantities.com/formulas/roof-pitch-and-slope/",
 "json": "https://craftquantities.com/formulas/roof-pitch-and-slope.json",
 "publisher": "Craft Quantities",
 "license": "https://creativecommons.org/licenses/by/4.0/",
 "licenseName": "CC BY 4.0",
 "note": "These are quantity equations, not design checks. Nothing here sizes a member or confirms that a structure is safe; that is for the engineer or building official responsible for the work.",
 "expressionSyntax": {
  "operators": [
   "+",
   "-",
   "*",
   "/",
   "^"
  ],
  "functions": {
   "sqrt": "square root",
   "ceil": "round up to the next whole number",
   "floor": "round down to the whole number below",
   "round": "round to the nearest whole number",
   "max": "the largest of its arguments",
   "atan_deg": "arctangent, in degrees"
  },
  "constants": {
   "pi": "π"
  }
 },
 "formulas": [
  {
   "id": "pitch-to-angle",
   "name": "Pitch to angle",
   "gives": "The angle of a roof from its pitch in rise per 12.",
   "equation": "θ = arctan(x / 12)",
   "expression": "atan_deg(x / 12)",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>θ</mi><mo>=</mo><mrow><mi>arctan</mi><mo>&#8289;</mo><mrow><mo>(</mo><mfrac><mrow><mi>x</mi></mrow><mrow><mn>12</mn></mrow></mfrac><mo>)</mo></mrow></mrow></mrow></math>",
   "output": {
    "id": "theta",
    "symbol": "θ",
    "meaning": "Angle from horizontal, degrees",
    "unit": {
     "metric": "°",
     "imperial": "°"
    }
   },
   "inputs": [
    {
     "id": "x",
     "symbol": "x",
     "meaning": "Rise per 12 of run",
     "unit": {
      "metric": "",
      "imperial": ""
     }
    }
   ],
   "calculators": [
    {
     "slug": "roof-pitch-angle-calculator",
     "title": "Roof Pitch to Angle Calculator",
     "url": "https://craftquantities.com/calculators/measurements-conversions/roof-pitch-angle-calculator/",
     "reproduces": "result"
    },
    {
     "slug": "roof-pitch-to-degrees-calculator",
     "title": "Roof Pitch to Degrees Calculator",
     "url": "https://craftquantities.com/calculators/renovation-construction/roof-pitch-to-degrees-calculator/",
     "reproduces": "result"
    }
   ],
   "testVectors": [
    {
     "calculator": "roof-pitch-angle-calculator",
     "testCase": "6/12 pitch",
     "inputs": {
      "x": 6
     },
     "output": 26.5650511771,
     "calculatorOutput": {
      "value": 26.5650511771,
      "unit": "degrees",
      "from": "result"
     },
     "pinned": {
      "expected": 26.565,
      "toleranceDecimalPlaces": 0.1
     }
    },
    {
     "calculator": "roof-pitch-angle-calculator",
     "testCase": "4/12 pitch",
     "inputs": {
      "x": 4
     },
     "output": 18.4349488229,
     "calculatorOutput": {
      "value": 18.4349488229,
      "unit": "degrees",
      "from": "result"
     },
     "pinned": {
      "expected": 18.435,
      "toleranceDecimalPlaces": 0.1
     }
    },
    {
     "calculator": "roof-pitch-to-degrees-calculator",
     "testCase": "6 in converts correctly",
     "inputs": {
      "x": 6
     },
     "output": 26.5650511771,
     "calculatorOutput": {
      "value": 26.5650511771,
      "unit": "°",
      "from": "result"
     },
     "pinned": {
      "expected": 26.56505117707799,
      "toleranceDecimalPlaces": 6
     }
    },
    {
     "calculator": "roof-pitch-to-degrees-calculator",
     "testCase": "Ten times the input",
     "inputs": {
      "x": 60
     },
     "output": 78.690067526,
     "calculatorOutput": {
      "value": 78.690067526,
      "unit": "°",
      "from": "result"
     },
     "pinned": {
      "expected": 78.69006752597979,
      "toleranceDecimalPlaces": 6
     }
    }
   ]
  },
  {
   "id": "grade-percent",
   "name": "Grade in per cent",
   "gives": "The grade of a slope from its rise and horizontal run.",
   "equation": "p = 100 × (Δh / L)",
   "expression": "100 * (dh / Lr)",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>p</mi><mo>=</mo><mrow><mn>100</mn><mo>&#215;</mo><mfrac><mrow><mi>Δh</mi></mrow><mrow><mi>L</mi></mrow></mfrac></mrow></mrow></math>",
   "output": {
    "id": "p",
    "symbol": "p",
    "meaning": "Grade, per cent",
    "unit": {
     "metric": "%",
     "imperial": "%"
    }
   },
   "inputs": [
    {
     "id": "dh",
     "symbol": "Δh",
     "meaning": "Rise",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "Lr",
     "symbol": "L",
     "meaning": "Horizontal run",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    }
   ],
   "calculators": [
    {
     "slug": "slope-grade-calculator",
     "title": "Slope & Grade Calculator",
     "url": "https://craftquantities.com/calculators/measurements-conversions/slope-grade-calculator/",
     "reproduces": "result"
    }
   ],
   "testVectors": [
    {
     "calculator": "slope-grade-calculator",
     "testCase": "1m rise over 12m run",
     "inputs": {
      "dh": 1,
      "Lr": 12
     },
     "output": 8.33333333333,
     "calculatorOutput": {
      "value": 8.33333333333,
      "unit": "%",
      "from": "result"
     },
     "pinned": {
      "expected": 8.333,
      "toleranceDecimalPlaces": 1
     }
    },
    {
     "calculator": "slope-grade-calculator",
     "testCase": "0.5m rise over 2m run",
     "inputs": {
      "dh": 0.5,
      "Lr": 2
     },
     "output": 25,
     "calculatorOutput": {
      "value": 25,
      "unit": "%",
      "from": "result"
     },
     "pinned": {
      "expected": 25,
      "toleranceDecimalPlaces": 0
     }
    }
   ]
  },
  {
   "id": "slope-angle",
   "name": "Slope angle",
   "gives": "The angle of a slope from its rise and horizontal run.",
   "equation": "θ = arctan(Δh / L)",
   "expression": "atan_deg(dh / Lr)",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>θ</mi><mo>=</mo><mrow><mi>arctan</mi><mo>&#8289;</mo><mrow><mo>(</mo><mfrac><mrow><mi>Δh</mi></mrow><mrow><mi>L</mi></mrow></mfrac><mo>)</mo></mrow></mrow></mrow></math>",
   "output": {
    "id": "theta",
    "symbol": "θ",
    "meaning": "Angle from horizontal, degrees",
    "unit": {
     "metric": "°",
     "imperial": "°"
    }
   },
   "inputs": [
    {
     "id": "dh",
     "symbol": "Δh",
     "meaning": "Rise",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "Lr",
     "symbol": "L",
     "meaning": "Horizontal run",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    }
   ],
   "calculators": [
    {
     "slug": "slope-grade-calculator",
     "title": "Slope & Grade Calculator",
     "url": "https://craftquantities.com/calculators/measurements-conversions/slope-grade-calculator/",
     "reproduces": {
      "breakdownLine": "Angle"
     }
    }
   ],
   "testVectors": [
    {
     "calculator": "slope-grade-calculator",
     "testCase": "1m rise over 12m run",
     "inputs": {
      "dh": 1,
      "Lr": 12
     },
     "output": 4.76364169073,
     "calculatorOutput": {
      "value": 4.76364169073,
      "unit": "degrees",
      "from": "breakdown",
      "line": "Angle"
     }
    },
    {
     "calculator": "slope-grade-calculator",
     "testCase": "0.5m rise over 2m run",
     "inputs": {
      "dh": 0.5,
      "Lr": 2
     },
     "output": 14.0362434679,
     "calculatorOutput": {
      "value": 14.0362434679,
      "unit": "degrees",
      "from": "breakdown",
      "line": "Angle"
     }
    }
   ]
  },
  {
   "id": "common-rafter-length",
   "name": "Common rafter length",
   "gives": "The length of a common rafter along the slope, overhang included.",
   "equation": "Lᵣ = (B / 2 + o) × √(1 + (x / 12)²)",
   "expression": "(B / 2 + o) * sqrt(1 + (x / 12) ^ 2)",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><msub><mi>L</mi><mi>r</mi></msub><mo>=</mo><mrow><mrow><mo>(</mo><mrow><mfrac><mrow><mi>B</mi></mrow><mrow><mn>2</mn></mrow></mfrac><mo>+</mo><mi>o</mi></mrow><mo>)</mo></mrow><mo>&#215;</mo><msqrt><mrow><mn>1</mn><mo>+</mo><msup><mrow><mo>(</mo><mfrac><mrow><mi>x</mi></mrow><mrow><mn>12</mn></mrow></mfrac><mo>)</mo></mrow><mrow><mn>2</mn></mrow></msup></mrow></msqrt></mrow></mrow></math>",
   "output": {
    "id": "R",
    "symbol": "L_r",
    "meaning": "Rafter length along the slope",
    "unit": {
     "metric": "m",
     "imperial": "ft"
    }
   },
   "inputs": [
    {
     "id": "B",
     "symbol": "B",
     "meaning": "Building width, wall to wall",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "o",
     "symbol": "o",
     "meaning": "Horizontal overhang",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "x",
     "symbol": "x",
     "meaning": "Pitch, rise per 12 of run",
     "unit": {
      "metric": "",
      "imperial": ""
     }
    }
   ],
   "calculators": [
    {
     "slug": "common-rafter-length-calculator",
     "title": "Common Gable Rafter Length Calculator",
     "url": "https://craftquantities.com/calculators/materials-quantities/common-rafter-length-calculator/",
     "reproduces": "result"
    }
   ],
   "testVectors": [
    {
     "calculator": "common-rafter-length-calculator",
     "testCase": "8m building, 6/12 pitch, 0.4m overhang",
     "inputs": {
      "B": 8,
      "o": 0.4,
      "x": 6
     },
     "output": 4.9193495505,
     "calculatorOutput": {
      "value": 4.9193495505,
      "unit": "m",
      "from": "result"
     },
     "pinned": {
      "expected": 4.919,
      "toleranceDecimalPlaces": 1
     }
    },
    {
     "calculator": "common-rafter-length-calculator",
     "testCase": "10m building, 8/12 pitch, 0.5m overhang",
     "inputs": {
      "B": 10,
      "o": 0.5,
      "x": 8
     },
     "output": 6.61017733835,
     "calculatorOutput": {
      "value": 6.61017733835,
      "unit": "m",
      "from": "result"
     },
     "pinned": {
      "expected": 6.61,
      "toleranceDecimalPlaces": 1
     }
    }
   ]
  },
  {
   "id": "diagonal-of-a-rectangle",
   "name": "Diagonal of a rectangle",
   "gives": "The diagonal of a rectangle, or the hypotenuse of a right triangle, from its two sides.",
   "equation": "d = √(a² + b²)",
   "expression": "sqrt(a ^ 2 + b ^ 2)",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>d</mi><mo>=</mo><msqrt><mrow><msup><mi>a</mi><mrow><mn>2</mn></mrow></msup><mo>+</mo><msup><mi>b</mi><mrow><mn>2</mn></mrow></msup></mrow></msqrt></mrow></math>",
   "output": {
    "id": "d",
    "symbol": "d",
    "meaning": "Diagonal",
    "unit": {
     "metric": "m",
     "imperial": "ft"
    }
   },
   "inputs": [
    {
     "id": "a",
     "symbol": "a",
     "meaning": "One side",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "b",
     "symbol": "b",
     "meaning": "The other side",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    }
   ],
   "calculators": [
    {
     "slug": "layout-squaring-calculator",
     "title": "Squaring Calculator for Layout and Setting Out (3-4-5 Rule)",
     "url": "https://craftquantities.com/calculators/measurements-conversions/layout-squaring-calculator/",
     "reproduces": "result"
    }
   ],
   "testVectors": [
    {
     "calculator": "layout-squaring-calculator",
     "testCase": "3 and 4 from the corner: the diagonal reads 5",
     "inputs": {
      "a": 4,
      "b": 3
     },
     "output": 5,
     "calculatorOutput": {
      "value": 5,
      "unit": "m",
      "from": "result"
     },
     "pinned": {
      "expected": 5,
      "toleranceDecimalPlaces": 9
     }
    },
    {
     "calculator": "layout-squaring-calculator",
     "testCase": "the setting-out guide's 8 by 5 base reads 9.434 corner to corner",
     "inputs": {
      "a": 8,
      "b": 5
     },
     "output": 9.43398113206,
     "calculatorOutput": {
      "value": 9.43398113206,
      "unit": "m",
      "from": "result"
     },
     "pinned": {
      "expected": 9.433981,
      "toleranceDecimalPlaces": 5
     }
    },
    {
     "calculator": "layout-squaring-calculator",
     "testCase": "a 24 by 16 ft (7.32 by 4.88 m) slab reads 28.844 ft (8.792 m) corner to corner",
     "inputs": {
      "a": 7.3152,
      "b": 4.8768
     },
     "output": 8.79177623009,
     "calculatorOutput": {
      "value": 8.79177623009,
      "unit": "m",
      "from": "result"
     },
     "pinned": {
      "expected": 8.791776,
      "toleranceDecimalPlaces": 5
     }
    }
   ]
  }
 ],
 "sources": [
  {
   "label": "Roofing pitch is conventionally expressed as rise per 12 in of run (e.g. '6/12'); angle in degrees = arctangent(rise / 12)",
   "citedBy": [
    "roof-pitch-angle-calculator"
   ]
  },
  {
   "label": "Roof pitch expressed as rise per 12 units of run; angle = arctan(rise / 12)",
   "citedBy": [
    "roof-pitch-to-degrees-calculator"
   ]
  },
  {
   "label": "Common reference points: 4:12 = 18.43°, 6:12 = 26.57°, 12:12 = 45°",
   "citedBy": [
    "roof-pitch-to-degrees-calculator"
   ]
  },
  {
   "label": "Grade percent = (rise / run) x 100; angle in degrees = arctangent(rise / run)",
   "citedBy": [
    "slope-grade-calculator"
   ]
  },
  {
   "label": "Standard carpentry rafter-length formula: rafter length = run × √(1 + (rise/12)²), where run is the horizontal distance from wall plate to ridge",
   "citedBy": [
    "common-rafter-length-calculator"
   ]
  },
  {
   "label": "Euclid, Elements, Book I, Proposition 48 (D. E. Joyce's edition, Clark University): if the square on one side of a triangle equals the squares on the other two together, the angle between those two is right — which is why any multiple of 3, 4 and 5 makes a square corner — and Proposition 47, its converse, which gives the expected diagonal √(a² + b²)",
   "url": "https://mathcs.clarku.edu/~djoyce/elements/bookI/propI48.html",
   "citedBy": [
    "layout-squaring-calculator"
   ]
  },
  {
   "label": "The QUIKRETE Companies, Layout Basics for Slabs and Footers: stake out with the 3-4-5 triangular method, any multiple such as 6-8-10 or 9-12-15 giving the same result, then double-check for squareness by measuring the diagonals between opposite corners, which should be equal; batter boards set back from the work keep the lines",
   "url": "https://www.quikrete.com/PDFs/Projects/LayoutBasicsForSlabsAndFooters.pdf",
   "citedBy": [
    "layout-squaring-calculator"
   ]
  },
  {
   "label": "NIST Digital Library of Mathematical Functions, §4.42 Solution of Triangles, the law of cosines (4.42.5): the corner angle from its two sides and the diagonal across it, and, applied to the two halves of a parallelogram, d₁² + d₂² = 2(a² + b²) and d₁² − d₂² = 4ab·cos θ, from which the racked shift and angle follow",
   "url": "https://dlmf.nist.gov/4.42",
   "citedBy": [
    "layout-squaring-calculator"
   ]
  }
 ]
}
