not an easy task indeed, many algorithms that may be possible usable and implemented for something like this, are related to images, in the net web... see if this open source in c++ may help you:
http://www.cs.toronto.edu/~dmac/ShapeMatcher/
good luck!
i was going to write some code for this, but found this by Sean Tessier - COMPPOLY - i tried and works:
http://www.cadtutor.net/forum/archive/index.php/t-90196.html?s=49ca0f576039c0bb3ba068a4a4661272
that can be easily ported to ARX.
hth.-