__Shortest Distances__

__The Shortest Distance Between a Point and a Plane__

Suppose we are at point A, with position vector __a__, how do we calculate the distance to the nearest point of a nearby plane passing through point B and with a __unit__ normal vector __n__.

We know the vector from B to A = **b** - **a**, and with a little thought that the required distance is the component of **b** - **a** in the direction of the unit normal to the plane:

This distance is just the projection of **a** - __b__ on to the **unit** normal vector __n__

d = __n__ . ( **a** - __b__ )

__The Shortest Distance Between Two Skew Lines__

Relating maths to real life again (see the equation of the line), our starship is on a linear course, __r___{1}(t), between points A and B,

__r___{1}(t) = __a__ + t (**b** - __a__) where t is any real number

A second starship is on course, __r___{2}(t), between C and D,

__r___{2}(s) = __c__ + s (**d** - __c__) where s is any real number

Regulations state that the **path** of any 2 starships at warp (as we both happen to be) cannot come closer than 1000km of each other (note this refers to the courses and not just the ships). To check we're obeying regulations, we will find the shortest distance, d, that __r___{1}(t) and __r___{2}(s) ever come to each other.

Firstly, note we are going to assume the two lines are not parallel and non intersecting, then imagine the line our ship is following. There exist an infinite number of planes that contain the line, though only one of them does not intersect the line that the other ship is travelling along. I found this easier to see by constructing the plane as follows:

__b__ - **a** lies in the plane, and

__c__ - **d** is parallel to the plane also, so using the cross product,

__n__ = (__b__ - **a**) x (__c__ - **d**)

is a normal vector to the plane, and the plane passes through __a__ hence any point R in the plane satisfies

(**r** - __a__) . **n** = 0

The distance, d, we want to find is that between this plane and the plane parallel to this one that contains C and D (ie. the other ship's course)

We can calculate d by taking any vector that joins the 2 planes and projecting it onto the *unit* normal vector. The vector from A to D ( = **d** - **a** ) is one of them so we've all but done it:

d = | (**d** - **a**) . (__n__/ n)) |

where __n__ = (__b__ - **a**) x (__c__ - **d**)

and n = |__n__| = the magnitude of **n**

Contents