mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
I think of lerp() as a way to change coordinate systems, essentially remapping the input numberline onto a shifted+rescaled numberline. In my mind the full numberline is remapped, not just the 0-1 segment. An example of how this is useful: in a game, you can write: `myPos = lerp(pos0, pos1, easeOutBack(u))` for some `u` that changes from 0 to 1 over time. (see https://easings.net/#easeOutBack) This will animate `myPos` between `pos0` and `pos1`, overshooting the goal position `pos1` in a nicely-animated way. `easeOutBack(float)->float` is a pure function that overshoots 1, and by combining it with `lerp()` we can remap coordinates in other coordinate systems, making them overshoot in the same way. However, this overshooting is only possible because `easeOutBack(t)` sometimes exceeds the range 0-1 (e.g. `easeOutBack(0.5)` is 1.0877), which is not allowed by the current `math.lerp` implementation. This commit removes the asserts that prevented this use-case. Now, any value can be inputted for t. For example, `lerp(10,20, 2.0)` will now return 30, instead of throwing an assert error.