Before I reinvent this triangular wheel I thought I'd see if there's already some code that does this. The figure will be an outline although there could be loops (an 8 for example). Failing an existing algorithm, if you have a clever idea feel free to share. The more the merrier!