Hey fellow gamedevs: how do you lerp between A and B?
=> More informations about this toot | More toots from sstadnicki@mathstodon.xyz
@sstadnicki What are A and B in your case? If they are big lists of reals in memory, i.e. vector-like objects, then the first method is faster.
And also many thanks for introducing me to the word “lerp” (https://en.wiktionary.org/wiki/lerp#Verb). 🙂
=> More informations about this toot | More toots from mrdk@mathstodon.xyz
@sstadnicki No, it is more interesting:
Assume that we want to interpolate between two n-dimensional vectors of reals and the costs of a multiplication and an addition are m and a respectively. Then the cost of the first method is
(2m + a)n + a
and that of the second method is
(m + 2a)n.
This means that on very old hardware on which multiplication is an expensive operation, the second method is better. With modern floating-point processing, we have m = a and the methods are equivalent.
Here I have taken “costs” as something like the required time for the operation. If we take costs as energy consumption, then I think multiplication is still more expensive an the second method is still better.
=> More informations about this toot | More toots from mrdk@mathstodon.xyz
@mrdk @sstadnicki The second method might overflow in cases when neither A nor B overflow (if A is very negative and B very positive).
=> More informations about this toot | More toots from BrKloeckner@piaille.fr
@BrKloeckner I will get back to this. :-)
=> More informations about this toot | More toots from sstadnicki@mathstodon.xyz
@mrdk Largely agreed — with a little caveat that often it's used to interpolate between two lists of items where for one reason or another (1-t) frequently isn't precomputed, so the memoization of that value happens less often than it arguably 'should'.
=> More informations about this toot | More toots from sstadnicki@mathstodon.xyz This content has been proxied by September (3851b).Proxy Information
text/gemini