Open vertexclique opened 4 years ago
I am working on lerp, soon I will open a PR for it.
@rustbot claim
(I claimed it since there was no new PR after a year, also repurposing this as a tracking issue)
Just want to throw in some food for thought as I think it's loosely related:
In p5js, there is the map
function that can interpolate a value from an input range to an output range. This is more general than @clarfonthey's proposed lerp
as it doesn't assume a constant input range, but the downside is a lot more parameters.
I think if we were to introduce lerp
, a conceptual sibling normalize
would also be useful. normalize
would take a number and a range, and produce a value such that A.normalize(A, B) = 0
and B.normalize(A, B) = 1
. This would enable a map-like operation by chaining normalize
and lerp
: A.normalize(IN_MIN, IN_MAX).lerp(OUT_MIN, OUT_MAX)
.
@rustbot release-assignment
Currently, linear interpolation (aka
lerp
) andmidpoint
don't exist in std. But exists in C++20 forwards. It would be nice to have them.