Monday, March 18, 2019

mathematics - How do I linearly interpolate between two vectors?


I have a velocity vector where my client is at and where its going, and I have the same vector that comes from the server telling where the client should be. Sometimes its a bit different, so I want to interpolate between my current position to the server correct position.


enter image description here



The black arrow is the client velocity vector, the red arrow is the client velocity vector on the server and the blue arrow is the one that I want to calculate and interpolate to.


How do I calculate the blue vector? Then, how can I linear interpolate between them?



Answer



Blue vector can be calculated easily: red - black (the sign between vectors is minus). But if you want just to interpolate between black and red vector, you don't have to calculate it. Linear interpolation is just linear combination. So you can just take: alpha * black + (1 - alpha) * red, where alpha has to be from interval <0,1>. If alpha will be 1, then you will get black vector, when alpha is 0, you will get red vector.


And if I understood it right, you will interpolate between these vectors in time. So just choose right increment of alpha in time.


Did I understand you right? Or did you meant something completelly diffent?


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...