I've seen a couple of lerp functions, mainly for lerping vectors, and they seem to go like this:
vector lerp(float bias, vector start, vector end)
{ return (1-bias) * start + bias * end; }
Whereas my naive way of doing it would be:
vector lerp(float bias, vector start, vector end)
{ return (end - start) * bias + start;
I following shows the breakdown of the two methods:
two float by vector multiplications | one vector addition | one float subtraction |
one float by vector multiplication | one vector addition and one vector subtraction |
Simplified, that means:
6 float multiplications | 3 additions | one float subtraction
3 float multiplications | 6 additions |
Am I mixed and have got the wrong idea that these are equivalent? I struggle sometimes with simple math concepts.
Edit: I just realised, in my case I need a halfway lerp, which is even cheaper to be done by getting the average of the two vectors' components. That's simply one addition and one multiplication for each axis, X, Y, Z. I think I'll do that.