I have a line that exists in 3D that is between two known points: {X1, Y1, Z1} and {X2, Y2, Z2}.
(X1,Y1,X1)----------(X2,Y2,Z2)
There is a point (Xd,Yd,Zd) on the line between those points at distance D from (X1,Y1,Z1).
(X1,Y1,X1)---D---(Xd,Yd,Zd)-----(X2,Y2,Z2)
How can I determine the coordinates of point (Xd,Yd,Zd)?
Assuming you want to move the distance D from point 1 to point 2 :
P1 = [ X1, Y1, Z1 ]
P2 = [ X2, Y2, Z2 ]
The line vector can be described as :
V = P2 - P1 = [ Xv = X2 - X1, Yv = Y2 - Y1, Zv = Z2 - Z1 ]
The line's length can be determined as :
VL = SQRT(Xv^2 + Yv^2 + Zv^2) // ^2 = squared
The line's versor aka the unit vector can be determined as :
v = V / VL = [Xv / VL, Yv / VL, Zv / VL]
The target point PD can be determined as :
Pd = P1 + D * v // Starting from P1 advance D times v
Please note that P1 and v are vectors and D is a scalar