let's say there is 3 points in 3D $p0$ , $p1$ , $p2$ , $l = p2-p1$ forms the line segment
and $p0$ is like isolated on its own. how can I find a point $q$ on $l$ that is away from $p0$ such that $||p0-q|| = d$ ? ($d$ is any distance)
my attempt :
$q = p1+s(p2-p1) = p1+sl$ for $0 =< s =< 1$
now $||p0-p1+sl|| = d $ ? I'm stuck here
I know that terms like s are revealed with dotProduct equations but I can't seem to find a meaningful one here, so how to find s essentially? Ho and every variable is known but s of course
Say that $p_{0}=(y_{1}, y_{2}, y_{3})$, $p_{1}=(x_{1}, x_{2}, x_{3})$ and $l=(z_{1}, z_{1}, z_{3})$
Call $v$ the vector $v = p_{0}-p_{1}-sl$, then $v=(y_{1}-x_{1}-sz_{1}, y_{2}-x_{2}-sz_{2}, y_{3}-x_{2}-sz_{3})$
You must solve $v^2 = d^2$, or $v \cdot v = d^2$. Just apply the dot product of $v$ with itself and you will get a second degree equation in $s$ (note that every other variable is known). The trick here is to square.
You will get $(y_{1}-x_{1}-sz_{1})^2 + (y_2-x_2-sz_2)^2 + (y_3-x_3-sz_3)^2 = d^2$, which you only have to develop, giving you:
$(z_1^2+z_2^2+z_3^2) s^2 + 2(x_1z_1 + x_2z_2 + x_3z_3 - y_1z_1 - y_2z_2 - y_3z_3)s + (y_1^2+x_1^2+y_2^2+x_2^2+y_3^2+x_3^2 - 2y_1x_1 - 2y_2x_2 - 2y_3x_3 -d^2) = 0$