# Finding the next point

i want to find a 3rd point from 2 other points in 3d space

``````Vector3 A;
Vector3 B;

float Dist;

public Vector3 FindPoint ( Vector3 a,Vector3 b,float d )
{
A = a;
B = b;

Dist = d;

Vector3 NewP = HowWouldIDoThis ();

return NewP;

}
``````

point a is the start, b the next point and we need to find the third point, in line with the first 2, and Dist away from the second point.

B + (B - A).normalized * Dist

(B - A) gives you a vector from A to B. Normalizing it makes it a unit vector (of length 1). Multiplying it by Dist makes the vector length Dist (1 * Dist = Dist). Adding that to B gives you a point in that direction and distance from B… your desired result.

Personally I wouldn’t call this “FindPoint”… personally I use the word Find for locating something that already exists by some identifier. Like you “Find” a gameobject in your scene by its name.

I’d use the word “Calculate”… like “CalculatePointOnLine”.

Thank you. Nice and simple,. And yes thank you for pointing out my descriptive mistake.