# Finding both the longest and shortest path in a convex polygon

Let $S$ be a convex polygon on $n$ points. Given two points $A$ and $B$, where $A$ is left of $S$, and $B$ is right of $S$, what's an algorithm to find the shortest path from $A$ to $B$, that avoids the interior of $S$? What about the longest path?

• Are A and B on the edges of S, or are they vertices of S? Are you asking how to choose the shorter of the two paths around the border of a polygon? Oct 1, 2013 at 16:33
• A and B are not points of S. A is left of S & B is right of S.
– user9665
Oct 1, 2013 at 16:40
• Is the longest path even well defined here? If I give you a path, can't you always find a longer one?
– Juho
Oct 1, 2013 at 16:42
• To make your question more clear you should use words outside and around instead of in. Oct 1, 2013 at 17:06

A smarter solution would be to find the points P, minimizing and maximizing the angle between $\vec {AP}$ and $\vec {AB}$. Those will be the points where your path enters and leaves S.