I have it as a lerp function:
Vec2f lerp(float t, Vec2f a, Vec2f b){ return (1-t)*a + t*b; }
And I have the following code below, which I was hoping this would lead to "tween":
Vec2f a(0,0); Vec2f b(3,4); Vec2f c(5,4); Vec2f d(5,0); if( i < 100 ){ if(i <= 30){ ball.pos = lerp(i, a, b); } else if(i > 30 && i < 80){ ball.pos = lerp(i, b, c); } else { ball.pos = lerp(i, a, d); } } i += 1;
But I get an "intermittent twin", that is, instead of starting from the last point where lerp ends from A to B, it starts somewhere else, and some go for other lerps. What am I doing wrong?
source share