0
$\begingroup$

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!

$\endgroup$
2
$\begingroup$

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$.

| cite | improve this answer | |
$\endgroup$
2
$\begingroup$
  1. find a vector that points toward $P_2$ from $P_1$. That's $$\vec v = P_2 - P_1 = (x_2-x_1, y_2-y_1, z_2-z_1)$$
  2. find a vector of length 1 in that same direction. This can be done by finding the length $$|\vec v|=\sqrt{x_v^2+y_v^2+z_v^2}$$ and dividing the components of $v$ by it: $$\vec v^* = \frac{\vec v}{|\vec v|}=\left(\frac{x_v}{|\vec v|},\frac{y_v}{|\vec v|},\frac{z_v}{|\vec v|}\right)$$
  3. find a vector of length $D$ in that same direction. $$d=D\vec v^*=(Dx_v^*,Dy_v^*,Dx_v^*)$$
  4. $P_3$ is now $d$ away from $P_2$. $$P_3=P_2+d=(x_2+x_d,y_2+y_d,z_2+z_d)$$
| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.