I'm coding automated movement in my raycasting prog at the moment. It uses A* to find a path, then rotates to face the next tile to move to. I want to find out what direction to turn in will take the least rotation.
So say I know the target facing I want to reach. I have 2 player directions dir_x and dir_y, which range between -1 and 1. How can I find which direction will take the least rotation?
Heres an sketch. Ignore the blue writing its just random crap. The red dot represents the player. Theres an example target of dir_x = 0.5, dir_y = 0.5. Any facing in the green half of the grid would be rotated to the right, whereas anything in the turquoise half would be rotated to the left.

I hope I explained this in an understandable way. If I dident, let me know. Cheers