User:KohanX/Formulae

The distance between two lines $$\mathbf{A}$$ and $$\mathbf{B}$$, where $$\mathbf{a}$$ and $$\mathbf{b}$$ are the respective directions, and $$\mathbf{a^0}$$ and $$\mathbf{b^0}$$ are an arbitrary point along said lines, respectively. Both the directions and points are vectors, of course.

$$d(\mathbf{A},\mathbf{B})=\bigg|(\mathbf{a^0}-\mathbf{b^0})+\frac{((\mathbf{a}\cdot\mathbf{b})(\mathbf{b}\cdot(\mathbf{a^0}-\mathbf{b^0}))-(\mathbf{a}\cdot(\mathbf{a^0}-\mathbf{b^0})))\mathbf{a}-((\mathbf{b}\cdot(\mathbf{a^0}-\mathbf{b^0}))-(\mathbf{a}\cdot\mathbf{b})(\mathbf{a}\cdot(\mathbf{a^0}-\mathbf{b^0})))\mathbf{b}}{1-(\mathbf{a}\cdot\mathbf{b})^2}\bigg|$$