{
  "schemaVersion": 1,
  "slug": "focal-length-calculator",
  "category": "photography",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "21fdcd0ccc31024fa9129545dd2d58be940540fb68d80eab3c247eebfcfd52e5",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/focal-length-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": "u = max(10, F) ÷ 100; f = D × 1000 × s × u ÷ (H × 1000 + s × u); α = 2 × atan(s ÷ (2f)) × 180 ÷ π",
    "vars": [
      [
        "H",
        "subject height (m)"
      ],
      [
        "D",
        "shooting distance (m)"
      ],
      [
        "s",
        "sensor dimension (mm)"
      ],
      [
        "F",
        "frame fill (%)"
      ],
      [
        "u",
        "fill fraction (10% floor)"
      ],
      [
        "f",
        "focal length (mm)"
      ],
      [
        "α",
        "angle of view (°)"
      ]
    ],
    "note": "u is the fill fraction with a 10% floor; magnification = s × u ÷ (H × 1000); field of view = D × s ÷ f."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const fill = Math.max(10, frameFill)/100; const imageH = sensor*fill; const mag = imageH/(subjectHeight*1000); const f = distance*1000*imageH/(subjectHeight*1000 + imageH); const aov = 2*Math.atan(sensor/(2*f))*180/Math.PI; return { focalLength: f, magnification: mag, angleOfView: aov, imageHeightMm: imageH, fieldOfView: distance*sensor/(f || 1) };",
    "inputs": [
      {
        "name": "subjectHeight",
        "type": "number",
        "default": 1.8,
        "min": 0.001,
        "max": 10000,
        "step": 0.01
      },
      {
        "name": "distance",
        "type": "number",
        "default": 10,
        "min": 0.01,
        "max": 100000,
        "step": 0.1
      },
      {
        "name": "sensor",
        "type": "select",
        "default": 24,
        "options": [
          {
            "value": 24
          },
          {
            "value": 15.6
          },
          {
            "value": 13
          },
          {
            "value": 8.8
          }
        ]
      },
      {
        "name": "frameFill",
        "type": "number",
        "default": 90,
        "min": 10,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "focalLength",
        "precision": 1,
        "unit": "mm"
      },
      {
        "name": "magnification",
        "precision": 4,
        "unit": "x"
      },
      {
        "name": "angleOfView",
        "precision": 2,
        "unit": "degrees"
      },
      {
        "name": "imageHeightMm",
        "precision": 2,
        "unit": "mm"
      },
      {
        "name": "fieldOfView",
        "precision": 2,
        "unit": "m"
      }
    ],
    "interpret": null
  }
}
