Distance between two polylines : <p>I want to calculate the distance <em>d</em> between two polylines:</p>

<p><a href="https://i.stack.imgur.com/1mdId.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1mdId.png" alt="polyline-polyline-distance"></a></p>

<p>Obviously I could check the distance for all pairs of line-segments and choose the smallest distance, but this ways the algorithmn would have a runtime of <em>O(n<sup>2</sup>)</em>. Is there any better approach?</p>
