MCPcopy
hub / github.com/cpaczek/skylight / zoomUnitsFromHfov

Function zoomUnitsFromHfov

shared/src/aim.ts:554–569  ·  view source on GitHub ↗
(hfovDeg: number, lut: FovPoint[])

Source from the content-addressed store, hash-verified

552}
553
554export function zoomUnitsFromHfov(hfovDeg: number, lut: FovPoint[]): number {
555 const pts = [...lut].sort((a, b) => b.hfovDeg - a.hfovDeg); // wide -> tele
556 if (pts.length === 0) return 0;
557 if (hfovDeg >= pts[0].hfovDeg) return pts[0].units;
558 const last = pts[pts.length - 1];
559 if (hfovDeg <= last.hfovDeg) return last.units;
560 for (let i = 1; i < pts.length; i++) {
561 if (hfovDeg >= pts[i].hfovDeg) {
562 const a = toLogTan(pts[i - 1].hfovDeg);
563 const b = toLogTan(pts[i].hfovDeg);
564 const f = (toLogTan(hfovDeg) - a) / (b - a);
565 return Math.round(pts[i - 1].units * (1 - f) + pts[i].units * f);
566 }
567 }
568 return last.units;
569}
570
571/**
572 * The HFOV to command: frame the plane at ~1/4–1/3 of frame height, but never

Callers 3

tickMethod · 0.85
chooseZoomFunction · 0.85

Calls 1

toLogTanFunction · 0.85

Tested by

no test coverage detected