'2D Registration of two shapes

I am having a task to implement a way of registration of two 2D Shapes. The first shape is the source, meaning it will never change, and the target shape is the shape that must be always aligned/registered on the source shape. For both shapes I have the X,Y coordinates.

In order to understand the problem, I'm adding a photo that explains it.

Blue is the Source Shape, Red is the Target Shape

The Angle of the rotation of Red shape is unknown and cannot be for every random red shape the same. So I need an algorithm to find the best rotation in order to match the blue shape.

Any ideas?? I've read about ICP but does it work for 2D problems? Because I used an implementation but for the 2D data it never converged, but for 3D data I found was working perfectly.

Thanks in advance,



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source