[Math] Find 3rd point in 3D space based on position of 2 points

3d

Assuming i have 2 points $P_1$ and $P_2$ having coordinates of

$P_1 = (x_1, y_1, z_1)$

$P_2 = (x_2, y_2, z_2)$

I want to find the coordinates of a 3rd point ($P_3$) where it creates a straight line if connected with $P_1$ and $P_2$

P3 should be after $P_2$ on the virtually-created-line (aka –$P_1$–$P_2$–$P_3$–) and should have distance $D$ from $P_2$

Thanks!

Best Answer

The solution is $$ \vec{P_2}+D\frac{\vec{P_1P_2}}{|\vec{P_1P_2}|} $$ You take the vector $P_2$, and you add $D$ times the unit (length one) vector that points from $P_1$ towards $P_2$.