If given 2 lines $\alpha$ and $\beta$, that are created by
- 2 points: A and B
- 2 plane intersection
I want to find shortest distance between them.
$$\left\{\begin{array}{c} P_1=x_1X+y_1Y+z_1Z+C=0 \\ P_2=x_2X+y_2Y+z_2Z+C=0\end{array}\right.$$
$$A=\left(x_3;y_3;z_3\right)$$
$$B=\left(x_4;y_4;z_4\right)$$
$$\alpha =n_1\times n_2=\left(\left|\begin{array}{cc} y_1 & z_1 \\ y_2 & z_2\end{array}\right|;-\left|\begin{array}{cc} x_1 & z_1 \\ x_2 & z_2\end{array}\right|;\left|\begin{array}{cc} x_1 & y_1 \\ x_2 & y_2\end{array}\right|\right)$$
$$\beta =$$
From here I tried:
The question of "shortest distance" is
only interesting in the skew case.
Let's say $p_0$ and $p_1$ are points on the
lines $L_0$ and $L_1$, respectively. Also $d_0$
and $d_1$ are the direction vectors of $L_0$
and $L_1$, respectively. The shortest
distance is $(p_0 – p_1)$ * , in which *
is dot product, and is the normalized
cross product. The point on $L_0$ that is
nearest to $L_1$ is $p_0 + d_0(((p_1 – p_0) *
k) / (d_0 * k))$, in which $k$ is $d_1 \times d_0 \times d_1$.
I tried, but failed.
Best Answer
Per this wikipedia article, if your lines are $\vec{X}=\vec{X_1}+t\vec{D_1}$ and $\vec{X}=\vec{X_2}+t\vec{D_2}$, the distance between them is $$\left|\frac{\vec{D_1}\times\vec{D_2}}{|\vec{D_1}\times\vec{D_2}|}\cdot(\vec{X_1}-\vec{X_2})\right|.$$