## Calculate the extension of a line

Hi everyone,

I like to calculate the extension of line in 3D. Lets say we have p1(x,y,z) and p2(x,y,z).
The distance between p1 and p2 is eg. 10m.

Now I want to get the 3D points of C,D,E by a function:
The extension direction should go to the second argument in this case p2
verctor3 = GetLineExtenstionPoint(newDistance, p1, p2)
For sure minus newDistance should give the point between p1 and p2.

And the extension direction should direct to p1 in this case.
verctor3 = GetLineExtenstionPoint(newDistance, p2, p1)

Does anyone know how to?
Thanks a lot!

Lerp between them based on the ratio of the current distance and the desired distance… Take the normalized vector and move along it… Few ways to skin that cat.

something like this?
var n = vector3.Distance(p1,p2);
var newpos = Vector3.Lerp(p1, p2, n * newDistance);

hmm… I think n must be normalized