--- id: math-inverse_lerp name: Math.inverse_lerp category: math kind: namespace-method tokens: Math.inverse_lerp sig: Math.inverse_lerp(a, b, v) -> fixed tip: Find where a value sits between two endpoints as a 0..1 fraction. order: 9 ns: Math member: inverse_lerp --- The inverse of Math.lerp: given endpoints a and b and a value v, it returns the fraction (v - a) / (b - a) — 0.0 when v equals a, 1.0 when it equals b. Use it to turn a raw quantity into a normalized amount: how full a health bar is, how far a timer has run, or the t to feed into another Math.lerp. The endpoints must differ, since equal ones would divide by zero. Parameters: - `a` — the endpoint that maps to `0.0` - `b` — the endpoint that maps to `1.0` - `v` — the value to locate between them ```ludic program HealthFraction { const MAX_HP: fixed = 200.0 let hp: fixed = 150.0 handler Draw phase Render { let fraction = Math.inverse_lerp(0.0, MAX_HP, hp) # 0.75 } } ```