[AS2.0] Issue with angles and Math.atan2

Hey guys!

It’s been some time since I’ve posted in this section, but I have an interesting issue on my hands. It’s not something I can’t get over, but I want to see your ideas too, since I might be concentrating too much on one approach.

So let’s begin. I want to build a wheel which you can spin, similar to a roulette wheel. You can do this both ways (CW and CCW, this issue causing the bug, actually). The wheel has some acceleration to it too, and I achieve this by measuring the start and final angle of the drag movement, using Math.atan2(dy, dx).

The problem is the following: atan2 outputs the following angle scheme, assuming the point relative to which the math is done is in the center of the circle.

atan2 returns a value measured in radians, so I’m using the classic angle*180/Math.PI formula.

I’ve changed this original scheme into the following, using some simple math to shift the angles a bit, to resemble more accurate circle angles (going up to 360 degrees)

The problem that I’m facing at the moment is should the user decide he wants to swipe clockwise, and moves through the right point, where 0 turns into 360 or 180 turns into -180, the whole angle difference thing is capsized. It registers a CCW movement (as if the user swiped his mouse all around the circle).

So, I’m looking for some ideas as to how I can work around this small issue.

Thanks, and see you!