{
  "schemaVersion": 1,
  "slug": "screen-size-distance-calculator",
  "category": "everyday",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "d4c8a1469d8097db5eccfbafa4875b2a29b99e09c18096f08d4898c4859e5580",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/screen-size-distance-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "W = S × a ÷ √(a² + 1); d_min = S × r × 0.6 × u ÷ 12; d_max = S × r × 2.2 × u ÷ 12; d_ideal = (d_min + d_max) ÷ 2",
    "vars": [
      [
        "S",
        "Screen diagonal (in)"
      ],
      [
        "a",
        "Aspect ratio"
      ],
      [
        "r",
        "Resolution factor"
      ],
      [
        "u",
        "Usage factor"
      ],
      [
        "d_min/d_max",
        "Viewing distance range (ft)"
      ]
    ],
    "note": "Distance range = diagonal × resolution factor × use factor × 0.6–2.2 ÷ 12. Recommended size inverts the midpoint equation and divides by both factors; all values are heuristics, not viewing standards."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const R = { '1080p': 1.6, '1440p': 1.2, '4k': 0.75, '8k': 0.4 }; const AR = { '16:9': 16/9, '21:9': 21/9, '4:3': 4/3 }; const ar = AR[aspect] || 16/9; const r = R[resolution] || 0.75; const U = { movies: 1.2, mixed: 1, tv: 0.75, gaming: 0.7 }; const u = U[use] || 1; const width = screenSize*ar/Math.sqrt(ar*ar+1); const height = screenSize/Math.sqrt(ar*ar+1); const minDistance = screenSize*r*0.6/12*u; const maxDistance = screenSize*r*2.2/12*u; const idealDistance = (minDistance+maxDistance)/2; return { screenWidth: width, screenHeight: height, minDistance, maxDistance, idealDistance, recommendedSize: r > 0 ? roomDistance*12/((0.6+2.2)/2*r*u) : 0 };",
    "inputs": [
      {
        "name": "screenSize",
        "type": "number",
        "default": 55,
        "min": 5,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "resolution",
        "type": "select",
        "default": "4k",
        "options": [
          {
            "value": "1080p"
          },
          {
            "value": "1440p"
          },
          {
            "value": "4k"
          },
          {
            "value": "8k"
          }
        ]
      },
      {
        "name": "aspect",
        "type": "select",
        "default": "16:9",
        "options": [
          {
            "value": "16:9"
          },
          {
            "value": "21:9"
          },
          {
            "value": "4:3"
          }
        ]
      },
      {
        "name": "roomDistance",
        "type": "number",
        "default": 9,
        "min": 1,
        "max": 60,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "use",
        "type": "select",
        "default": "mixed",
        "options": [
          {
            "value": "movies"
          },
          {
            "value": "mixed"
          },
          {
            "value": "tv"
          },
          {
            "value": "gaming"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "screenWidth",
        "precision": 1,
        "unit": "in"
      },
      {
        "name": "screenHeight",
        "precision": 1,
        "unit": "in"
      },
      {
        "name": "minDistance",
        "precision": 1,
        "unit": "ft"
      },
      {
        "name": "maxDistance",
        "precision": 1,
        "unit": "ft"
      },
      {
        "name": "idealDistance",
        "precision": 1,
        "unit": "ft"
      },
      {
        "name": "recommendedSize",
        "precision": 0,
        "unit": "in"
      }
    ],
    "interpret": null
  }
}
