how to detect an object's position by its rotation

I’m trying to build something like a puzzle, so the images rotate on their position when clicked, but there’s only one right position, here’s where the problem begins. I’ve been given it a lot of thinking and I really don’t find a good answer.

I thought of using a simple if condition, so I can compare the right rotation (giving that only one rotation is correct) but it gets more complicated as the number of images increases, besides this puzzle is a game where basically you need to find a way out by moving the images (curves, lines) so there could be more than just 1 answer (I’m designing just 1 right answer, but in larger puzzles it might be possible to have more than one answer by mistake)

So here is my question how do I detect if the end of a line (image) matches the beginnin of a curve (image) that is next to it? giving that I need to do the same with a lot of lines and curves that are up, down, right and left. [import]uid: 144222 topic_id: 27445 reply_id: 327445[/import]