# How to get a vector to interpolate between 2 points?

Title says it all, I suppose. How would I get a vector to interpolate between 2 other points?

Like, say I have 2 Vector3f’s defined, and another Vector3f that I want to move between those 2. I would normally call something like:

[java]vectorToInterp.interpolate(firstVector, 0.5f);[/java]

But when it reaches that point, how would I turn it around and get it to interpolate towards the other point?

For my specific application the only different value between the 2 vectors I want to interpolate between is the X. Other than that they’re exactly the same. So I could just interpolate a float to the first value, then to the second, back to the first, etc. but even still I’m at a loss as to how to do that. Any help?

[java]vectorToInterp.interpolate(firstVector, 0.5f);

if ( vectorToInterp.distance(firstVector) < 0.0001) { // I don’t know how close you want

firstVector = temp;

firstVector = secondVector;

secondVector = temp;

}[/java]

1 Like

I really should’ve thought about the distance method. Now I feel stupid. xD Thanks!