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

**URL:** <https://forum.kirupa.com/t/as2-0-issue-with-angles-and-math-atan2/324933>\
**Category:** flash\
**Created:** [September 16, 2011, 1:48pm UTC](https://forum.kirupa.com/t/as2-0-issue-with-angles-and-math-atan2/324933 "2011-09-16T13:48:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mastermode](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mastermode](https://forum.kirupa.com/u/mastermode)\
**Post date:** [September 16, 2011, 1:48pm UTC](https://forum.kirupa.com/t/as2-0-issue-with-angles-and-math-atan2/324933/1 "2011-09-16T13:48:44Z")

</div>

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.  
 ![](http://img717.imageshack.us/img717/9773/scheme1.th.png)

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)  
 ![](http://img10.imageshack.us/img10/6199/scheme2.png)

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!
