MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / tAtY

Function tAtY

ui/src/lib/screens-model.ts:643–657  ·  view source on GitHub ↗
(c: Curve, y: number, end: 'source' | 'target')

Source from the content-addressed store, hash-verified

641 * rises and falls, so it is searched on the half nearest `end`.
642 */
643export function tAtY(c: Curve, y: number, end: 'source' | 'target'): number | null {
644 const arch = c.y0 === c.y3;
645 let lo = arch && end === 'target' ? 0.5 : 0;
646 let hi = arch && end === 'source' ? 0.5 : 1;
647 const yLo = pointAt(c, lo).y;
648 const yHi = pointAt(c, hi).y;
649 if (y < Math.min(yLo, yHi) - 1e-6 || y > Math.max(yLo, yHi) + 1e-6) return null;
650 const rising = yHi > yLo;
651 for (let i = 0; i < 40; i++) {
652 const mid = (lo + hi) / 2;
653 if (pointAt(c, mid).y < y === rising) lo = mid;
654 else hi = mid;
655 }
656 return (lo + hi) / 2;
657}
658
659/* ---------------------------------------------------------------- pills -- */
660

Callers 2

layPillFunction · 0.85

Calls 1

pointAtFunction · 0.85

Tested by

no test coverage detected