The general segment matching algorithm seems to be correct and functional. However there is likely an implementation bug for the computation of segment areas, as they yield incorrect results, leading to poor matching. Simply using is not sufficient. Position might still be interesting.