TITLE: Find shortest path which intersects a point in a polygon
QUESTION [7 upvotes]: Sorry if I'm explaining this badly, math in English can be a bit troublesome.
I have a polygon, I have a random point inside that polygon. From this point I want a line "drawn" edge-to-edge and to intersect the point, but I want this line to be the shortest possible. See my image below:

The red dot indicates the random point inside polygon.
The green dotted line is the shortest path/line (which I'm looking for)
The blue vague line is just example of longer lines that does not match the criteria (shortest path of all paths).
And, obviously I want the path to intersect the red point.
(My real problem is that I want to find the line AND all the coordinates above that line, but that can be another problem for another day unless someone's feeling really ambitious)
Edit:
I want to do this because I want to somewhat (not true physics) simulate the (2D) behavior of cracking a rock and thus want to know what piece of the rock that should split away.
Also, a solution for a convex-polygon would suffice (even though the image shows a non-convex).

REPLY [2 votes]: Clearly we cannot expect a closed form solution, but a piecewise formula for the distance from each point in the polygon
and an algorithm to manage and find the minimum total distance you require is described in the following steps.
a) Translate the polygon so to bring the red point at the origin of the coordinates

b) Express the sides by the vectorial equation
$$
{\bf p}_k  = t_k {\bf v}_k  + \left( {1 - t_k } \right){\bf v}_{k + 1} \quad \left| \matrix{
  \;1 \le k \le n - 1 \hfill \cr 
  \;0 \le t_k  \le 1 \hfill \cr}  \right.
$$
c) Convert the sides equations into polar coordinates
That is
$$
\eqalign{
  & \left\{ \matrix{
  \rho _k \cos \alpha
  = t_k v_k \cos \alpha _k  + \left( {1 - t_k } \right)v_{k + 1} \cos \alpha _{k + 1}  \hfill \cr 
  \rho _k \sin \alpha
  = t_k v_k \sin \alpha _k  + \left( {1 - t_k } \right)v_{k + 1} \sin \alpha _{k + 1}  \hfill \cr}  \right.  \cr 
  & \quad \quad  \Downarrow   \cr 
  & \tan \alpha
  = {{t_k \left( {v_k \sin \alpha _k  - v_{k + 1} \sin \alpha _{k + 1} } \right) + v_{k + 1} \sin \alpha _{k + 1} }
  \over {t_k \left( {v_k \cos \alpha _k  - v_{k + 1} \cos \alpha _{k + 1} } \right) + v_{k + 1} \cos \alpha _{k + 1} }}  \cr 
  & \quad \quad  \Downarrow   \cr 
  & t_k
  = v_{k + 1} {{\sin \left( {\alpha _{k + 1}  - \alpha } \right)}
  \over {\left( {v_k \cos \alpha _k  - v_{k + 1} \cos \alpha _{k + 1} } \right)\sin \alpha
  - \left( {v_k \sin \alpha _k  - v_{k + 1} \sin \alpha _{k + 1} } \right)\cos \alpha }}  \cr 
  & \quad \quad  \Downarrow   \cr 
  & \left\{ \matrix{
  t_k (\alpha )
  = v_{k + 1} {{\sin \left( {\alpha _{k + 1}  - \alpha } \right)}
  \over {\left( {v_k \cos \alpha _k  - v_{k + 1} \cos \alpha _{k + 1} } \right)\sin \alpha
  - \left( {v_k \sin \alpha _k  - v_{k + 1} \sin \alpha _{k + 1} } \right)\cos \alpha }} \hfill \cr 
  \rho _k (\alpha )
 = {{\left( {v_k \cos \alpha _k  - v_{k + 1} \cos \alpha _{k + 1} } \right)t_k (\alpha ) + v_{k + 1} \cos \alpha _{k + 1} }
 \over {\cos \alpha }} \hfill \cr}  \right. \cr} 
$$
where the meaning of the symbols used is evident.
The expression is a bit complicated but well manageable on  computer.
d) Partition of angle intervals
Our scope is to find the minimum of $\rho (\alpha ) +\rho (\alpha + \pi ) $ and the relevant $\alpha$.
The function  $\rho (\alpha )$ expressed above is piecewise valid for $\alpha _{k} \le \alpha \le \alpha _{k+1}$.
To cope with our goal we will rearrange the angle intervals as follows.
Starting with the following array
$$
\left( {\matrix{ {\left[ {\alpha _1 ,\alpha _2 } \right)}  \cr {\rho _1 (\alpha )}  \cr  } } \right),
\left( {\matrix{ {\left[ {\alpha _2 ,\alpha _3 } \right)}  \cr {\rho _2 (\alpha )}  \cr } } \right),
 \cdots ,
\left( {\matrix{ {\left[ {\alpha _{n - 1} ,\alpha _n } \right)}  \cr {\rho _{n - 1} (\alpha )}  \cr  } } \right),
\left( {\matrix{ {\left[ {\alpha _n ,\alpha _1 } \right)}  \cr {\rho _n (\alpha )}  \cr } } \right)
$$
we insert $0 = 2 \pi$ and $\pi$
$$
\left( {\matrix{{\left[ {0,\alpha _1 } \right)}  \cr {\rho _n (\alpha )}  \cr } } \right),
\left( {\matrix{{\left[ {\alpha _1 ,\alpha _2 } \right)}  \cr {\rho _1 (\alpha )}  \cr } } \right),
 \cdots ,
\left( {\matrix{{\left[ {\alpha _m ,\pi } \right)}  \cr {\rho _m (\alpha )}  \cr } } \right),
\left( {\matrix{{\left[ {\pi ,\alpha _{m + 1} } \right)}  \cr {\rho _m (\alpha )}  \cr } } \right),
 \cdots ,
\left( {\matrix{{\left[ {\alpha _{n - 1} ,\alpha _n } \right)}  \cr {\rho _{n - 1} (\alpha )}  \cr } } \right),
\left( {\matrix{{\left[ {\alpha _n ,2\pi } \right)}  \cr {\rho _n (\alpha )}  \cr } } \right)
$$
At this point we consider the two sections of angle intervals
$$
\left\{ \matrix{
  \left[ {0,\alpha _1 } \right),\left[ {\alpha _1 ,\alpha _2 } \right), \cdots ,
 \left[ {\alpha _m ,\pi } \right) \hfill \cr 
  \left[ {\pi ,\alpha _{m + 1} } \right), \cdots ,
 \left[ {\alpha _{n - 1} ,\alpha _n } \right),\left[ {\alpha _n ,2\pi } \right) \hfill \cr}  \right.
$$
deduct $\pi$ from the values in the second
$$
\left\{ \matrix{
  \left[ {0,\alpha _1 } \right),\left[ {\alpha _1 ,\alpha _2 } \right), \cdots ,\left[ {\alpha _m ,\pi } \right) \hfill \cr 
  \left[ {0,\beta _1  = \alpha _{m + 1}  - \pi } \right), \cdots ,
\left[ {\beta _{n - m - 1} ,\beta _{n - m} } \right),\left[ {\beta _{n - m} ,\pi } \right) \hfill \cr}  \right.
$$
and then "compenetrate" the $\alpha$ and $\beta$ intervals, i.e. arrange $\alpha _k$ and $\beta _k$ sequentially,
into a congruent set of intervals  $ \cdots , \left[ {\gamma _{j},\gamma _{j+1} } \right), \cdots$ to
reach and get the following array
$$
 \cdots ,\left( {\matrix{
   {\left[ {\gamma _j ,\gamma _{j + 1} } \right)}  \cr 
   {r _{j} (\alpha ) = \rho _u (\alpha ) + \rho _v (\alpha  + \pi )}  \cr 
 } } \right), \cdots 
$$
Finally we can minimize each $r _{j} (\alpha )$ in its interval and choose the minimum.