Given a starting and ending position in the unit disk, what is the shortest path between the two points that also touches the unit circle? The starting point is labeled

*s* and drawn in green. The ending point is labeled

*e* and drawn in red, and the relative angle between them is β. The angle from the

*x*-axis to

*s* is ϕ. The shortest path touches the unit circle is at angle

.

The shortest path between two points that also touches the circumference is composed up of two straight line segments. The problem can be simplified by choosing the coordinate system carefully. We define the *x*-axis along the position of the starting point: S = (*s*,0), and define the point of intersection by the angle θ from the *x*-axis P = (cos(θ), sin(θ)), and the final point by a radius *e* and angle β, E = *e*(Cos(β), sin(β)). Then define a symmetry point about S of line OP named T.

Then the length of the two line segments is , which is minimized by choosing an appropriate θ value. This equation can be simplified to

. The

length of the two line segments as a function of θ is drawn in the right plot.

There are several simple solutions. If

*s* is 1 or

*e* is 0 or β is zero, the optimal angle

is 0. If

*e* is 1 or

*s* is 0, the optimal angle is β.

We label the origin O. The optimal solution shows that the angle ∠OPS (from the origin to P to S) is the same as the angle ∠OPE (from the origin to P to E).

We name these angles α. This can be proved by drawing an ellipse whose foci are S and E. When the ellipse is tangent to the circle, the point of tangency is exactly P.

Since the distance from the origin to P is always 1, we can set up three equalities using the law of sines:

From triangle OSP:

.

From triangle OEP:

.

If we mirror the point S about the θ axis, and label this point C, from triangle CEO:

.

Simplifying this system of equations results in:

*s*=*e* csc(θ)(*s** *sin(2 θ-β)+sin(β-θ)).

Solving this last equation results in a quartic solution. It has a closed form solution with four roots, each of which can be either a clockwise or a counterclockwise rotation θ, depending on the sign of β, with -π ≤ β ≤ π. We evaluate each and select the solution that results in the shortest length path.