{
 "schema": 1,
 "id": "spacing-and-count",
 "title": "Spacing and count",
 "description": "Members on centres, n = ⌈L/s⌉ + 1, members under a maximum gap and the equal gap between them, each pinned to test vectors.",
 "url": "https://craftquantities.com/formulas/spacing-and-count/",
 "json": "https://craftquantities.com/formulas/spacing-and-count.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": "count-on-centres",
   "name": "Members on centres",
   "gives": "How many members a run takes at a given centre-to-centre spacing, the closing one included.",
   "equation": "n = ⌈L / s⌉ + 1",
   "expression": "ceil(L / s) + 1",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>n</mi><mo>=</mo><mrow><mrow><mo>&#8968;</mo><mfrac><mrow><mi>L</mi></mrow><mrow><mi>s</mi></mrow></mfrac><mo>&#8969;</mo></mrow><mo>+</mo><mn>1</mn></mrow></mrow></math>",
   "output": {
    "id": "n",
    "symbol": "n",
    "meaning": "Number of members",
    "unit": {
     "metric": "",
     "imperial": ""
    }
   },
   "inputs": [
    {
     "id": "L",
     "symbol": "L",
     "meaning": "Length of the run",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "s",
     "symbol": "s",
     "meaning": "Centre-to-centre spacing",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    }
   ],
   "calculators": [
    {
     "slug": "linear-feet-to-studs-16-oc-calculator",
     "title": "Linear Feet to Studs Calculator (16 in OC)",
     "url": "https://craftquantities.com/calculators/renovation-construction/linear-feet-to-studs-16-oc-calculator/",
     "reproduces": "result"
    }
   ],
   "testVectors": [
    {
     "calculator": "linear-feet-to-studs-16-oc-calculator",
     "testCase": "40 ft wall",
     "inputs": {
      "L": 12.192,
      "s": 0.4064
     },
     "output": 31,
     "calculatorOutput": {
      "value": 31,
      "unit": "studs",
      "from": "result"
     },
     "pinned": {
      "expected": 31,
      "toleranceDecimalPlaces": 0
     }
    },
    {
     "calculator": "linear-feet-to-studs-16-oc-calculator",
     "testCase": "A length off the 16 in module still returns a whole count",
     "inputs": {
      "L": 10.0584,
      "s": 0.4064
     },
     "output": 26,
     "calculatorOutput": {
      "value": 26,
      "unit": "studs",
      "from": "result"
     },
     "pinned": {
      "expected": 26,
      "toleranceDecimalPlaces": 0
     }
    },
    {
     "calculator": "linear-feet-to-studs-16-oc-calculator",
     "testCase": "10 ft wall",
     "inputs": {
      "L": 3.048,
      "s": 0.4064
     },
     "output": 9,
     "calculatorOutput": {
      "value": 9,
      "unit": "studs",
      "from": "result"
     },
     "pinned": {
      "expected": 9,
      "toleranceDecimalPlaces": 0
     }
    }
   ]
  },
  {
   "id": "count-under-a-maximum-gap",
   "name": "Members under a maximum gap",
   "gives": "The fewest members that keep every clear gap at or under a limit.",
   "note": "The baluster calculator works to the 4 in (101.6 mm) gap of its US setting.",
   "equation": "n = ⌈(L − g_max) / (w + g_max)⌉",
   "expression": "ceil((L - g) / (w + g))",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>n</mi><mo>=</mo><mrow><mo>&#8968;</mo><mfrac><mrow><mrow><mi>L</mi><mo>&#8722;</mo><msub><mi>g</mi><mi>max</mi></msub></mrow></mrow><mrow><mrow><mi>w</mi><mo>+</mo><msub><mi>g</mi><mi>max</mi></msub></mrow></mrow></mfrac><mo>&#8969;</mo></mrow></mrow></math>",
   "output": {
    "id": "n",
    "symbol": "n",
    "meaning": "Number of members",
    "unit": {
     "metric": "",
     "imperial": ""
    }
   },
   "inputs": [
    {
     "id": "L",
     "symbol": "L",
     "meaning": "Clear length between the end supports",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "w",
     "symbol": "w",
     "meaning": "Width of one member",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "g",
     "symbol": "g_max",
     "meaning": "Largest clear gap allowed",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    }
   ],
   "calculators": [
    {
     "slug": "baluster-calculator",
     "title": "Deck Baluster Calculator",
     "url": "https://craftquantities.com/calculators/renovation-construction/baluster-calculator/",
     "reproduces": "result"
    }
   ],
   "testVectors": [
    {
     "calculator": "baluster-calculator",
     "testCase": "2.4m rail section, 1.5in balusters",
     "inputs": {
      "L": 2.4,
      "w": 0.0381,
      "g": 0.1016
     },
     "output": 17,
     "calculatorOutput": {
      "value": 17,
      "unit": "balusters",
      "from": "result"
     },
     "pinned": {
      "expected": 17,
      "toleranceDecimalPlaces": 0
     }
    },
    {
     "calculator": "baluster-calculator",
     "testCase": "1.8m rail section, 2in balusters",
     "inputs": {
      "L": 1.8,
      "w": 0.0508,
      "g": 0.1016
     },
     "output": 12,
     "calculatorOutput": {
      "value": 12,
      "unit": "balusters",
      "from": "result"
     },
     "pinned": {
      "expected": 12,
      "toleranceDecimalPlaces": 0
     }
    },
    {
     "calculator": "baluster-calculator",
     "testCase": "0.67m rail section, 41mm balusters (the span the two rules part on)",
     "inputs": {
      "L": 0.67,
      "w": 0.041,
      "g": 0.1016
     },
     "output": 4,
     "calculatorOutput": {
      "value": 4,
      "unit": "balusters",
      "from": "result"
     },
     "pinned": {
      "expected": 4,
      "toleranceDecimalPlaces": 0
     }
    }
   ]
  },
  {
   "id": "equal-gap-between-items",
   "name": "Equal gap between members",
   "gives": "The clear gap that spaces a known number of members evenly, with a gap at each end.",
   "equation": "g = (L − n × w) / (n + 1)",
   "expression": "(L - n * w) / (n + 1)",
   "mathml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><mrow><mi>g</mi><mo>=</mo><mfrac><mrow><mrow><mi>L</mi><mo>&#8722;</mo><mrow><mi>n</mi><mo>&#215;</mo><mi>w</mi></mrow></mrow></mrow><mrow><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></mrow></mfrac></mrow></math>",
   "output": {
    "id": "g",
    "symbol": "g",
    "meaning": "Clear gap",
    "unit": {
     "metric": "m",
     "imperial": "ft"
    }
   },
   "inputs": [
    {
     "id": "L",
     "symbol": "L",
     "meaning": "Clear length of the run",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    },
    {
     "id": "n",
     "symbol": "n",
     "meaning": "Number of members",
     "unit": {
      "metric": "",
      "imperial": ""
     }
    },
    {
     "id": "w",
     "symbol": "w",
     "meaning": "Width of one member",
     "unit": {
      "metric": "m",
      "imperial": "ft"
     }
    }
   ],
   "calculators": [
    {
     "slug": "baluster-calculator",
     "title": "Deck Baluster Calculator",
     "url": "https://craftquantities.com/calculators/renovation-construction/baluster-calculator/",
     "reproduces": {
      "breakdownLine": "Actual gap between balusters"
     }
    },
    {
     "slug": "equal-spacing-calculator",
     "title": "Equal Spacing Calculator (Balusters or Spindles, Posts, Battens)",
     "url": "https://craftquantities.com/calculators/measurements-conversions/equal-spacing-calculator/",
     "reproduces": {
      "breakdownLine": "Clear gap between items"
     }
    }
   ],
   "testVectors": [
    {
     "calculator": "baluster-calculator",
     "testCase": "2.4m rail section, 1.5in balusters",
     "inputs": {
      "L": 2.4,
      "n": 17,
      "w": 0.0381
     },
     "output": 0.09735,
     "calculatorOutput": {
      "value": 3.83267716535,
      "unit": "in",
      "from": "breakdown",
      "line": "Actual gap between balusters"
     }
    },
    {
     "calculator": "baluster-calculator",
     "testCase": "1.8m rail section, 2in balusters",
     "inputs": {
      "L": 1.8,
      "n": 12,
      "w": 0.0508
     },
     "output": 0.0915692307692,
     "calculatorOutput": {
      "value": 3.60508782556,
      "unit": "in",
      "from": "breakdown",
      "line": "Actual gap between balusters"
     }
    },
    {
     "calculator": "baluster-calculator",
     "testCase": "0.67m rail section, 41mm balusters (the span the two rules part on)",
     "inputs": {
      "L": 0.67,
      "n": 4,
      "w": 0.041
     },
     "output": 0.1012,
     "calculatorOutput": {
      "value": 3.9842519685,
      "unit": "in",
      "from": "breakdown",
      "line": "Actual gap between balusters"
     }
    },
    {
     "calculator": "equal-spacing-calculator",
     "testCase": "2.4 m between posts, 41 mm spindles, gaps at most 100 mm: 17 spindles",
     "inputs": {
      "L": 2.4,
      "n": 17,
      "w": 0.041
     },
     "output": 0.0946111111111,
     "calculatorOutput": {
      "value": 3.72484689414,
      "unit": "in (3 3/4 in)",
      "from": "breakdown",
      "line": "Clear gap between items"
     }
    },
    {
     "calculator": "equal-spacing-calculator",
     "testCase": "8 ft between posts, 1.5 in balusters, gaps at most 4 in: 17 balusters",
     "inputs": {
      "L": 2.4384,
      "n": 17,
      "w": 0.0381
     },
     "output": 0.0994833333333,
     "calculatorOutput": {
      "value": 3.91666666667,
      "unit": "in (3 15/16 in)",
      "from": "breakdown",
      "line": "Clear gap between items"
     }
    },
    {
     "calculator": "equal-spacing-calculator",
     "testCase": "660 mm at 40 mm spindles lands exactly on the 100 mm limit with 4 spindles",
     "inputs": {
      "L": 0.66,
      "n": 4,
      "w": 0.04
     },
     "output": 0.1,
     "calculatorOutput": {
      "value": 3.93700787402,
      "unit": "in (3 15/16 in)",
      "from": "breakdown",
      "line": "Clear gap between items"
     }
    }
   ]
  }
 ],
 "sources": [
  {
   "label": "16 in on centre spacing gives 0.75 studs per linear foot of wall",
   "citedBy": [
    "linear-feet-to-studs-16-oc-calculator"
   ]
  },
  {
   "label": "24 in on centre gives 0.5 studs per linear foot; advanced framing uses this where the structure permits",
   "citedBy": [
    "linear-feet-to-studs-16-oc-calculator"
   ]
  },
  {
   "label": "US: International Residential Code R312.1.3 — openings in a required guard must not allow passage of a 4 in (101.6 mm) diameter sphere; the imperial page solves to it",
   "citedBy": [
    "baluster-calculator"
   ]
  },
  {
   "label": "UK: Approved Document K (2013), Section 3 — guarding in a building likely to be used by children under five should not have openings that allow passage of a 100 mm (3.94 in) sphere; the metric page solves to it",
   "citedBy": [
    "baluster-calculator"
   ]
  },
  {
   "label": "International Residential Code R312.1.3 — openings in a required guard must not allow passage of a 4 in (101.6 mm) diameter sphere; one example of the maximum a reader enters",
   "citedBy": [
    "equal-spacing-calculator"
   ]
  },
  {
   "label": "Approved Document K (2013 edition), Section 3 — guarding in a building likely to be used by children under five should not have openings that allow passage of a 100 mm (3.94 in) sphere; the metric example",
   "citedBy": [
    "equal-spacing-calculator"
   ]
  },
  {
   "label": "NIST Handbook 44 (2026 edition), Appendix C: 12 inches = 1 foot and 1 inch = 2.54 centimetres exactly, the basis of the tape readings and of the millimetres a metric reader is shown",
   "url": "https://www.nist.gov/document/2026-nist-handbook-44-appendix-c",
   "citedBy": [
    "equal-spacing-calculator"
   ]
  }
 ]
}
