The animation of the orientation button behaved strangely in the main example. It spinned a lot while the map just turned around 30 degrees. The problem is that the angle to turns calculation were incorrect. For example, if the angle is incremented from 0 to 30, then the value of turns will increase from 0 to 360 / 30 = 12. So the button will turn 12 times and return to north. I propose to change this to use 360 / angle. For the same example, it would return 0.083. So the button would turn just slightly, representing the 30 degree change happened to the map.
I've also found an off by one error in the angle wrapping part. If the angle value is reset with "angle > 360", then it will only be reset at 390 degrees. In my opinion "angle >= 360" is a better choice, so it jumps from 330 to 0 and then from 0 to 30 rather than from 330 to 360 and then back to 0.
The animation of the orientation button behaved strangely in the main example. It spinned a lot while the map just turned around 30 degrees. The problem is that the angle to turns calculation were incorrect. For example, if the angle is incremented from 0 to 30, then the value of turns will increase from 0 to 360 / 30 = 12. So the button will turn 12 times and return to north. I propose to change this to use 360 / angle. For the same example, it would return 0.083. So the button would turn just slightly, representing the 30 degree change happened to the map.
I've also found an off by one error in the angle wrapping part. If the angle value is reset with "angle > 360", then it will only be reset at 390 degrees. In my opinion "angle >= 360" is a better choice, so it jumps from 330 to 0 and then from 0 to 30 rather than from 330 to 360 and then back to 0.