Nearest way to new angle?
BlitzMax Forums/BlitzMax Programming/Nearest way to new angle?
| ||
I know it's been mentioned before, but the search turned up nothing. If I have an old angle, and a new one I want to rotate towards. How do I rotate the shortest way towards the new angle? Thanks in advance EDIT: Never mind. I figured it out. Was quite easy ;) |
| ||
Could you post some code to show how to do it? Would be nice to have it here if anyone tries to search for it again. ;) |
| ||
Here is the way I do it. http://www.blitzbasic.com/Community/posts.php?topic=52437#609499 |
| ||
I just hacked another function to just return my rotation speed:' Get turn direction Function GetAngleDir:Int(A1#, A2#) Local ret:Int ret = A1-A2 If ret >= 180 ret = -(360 - ret) Else If ret <= -180 ret = ret + 360 EndIf EndIf ' Adjust to speed as I don't want the range to next angle :) If (ret <= 0) Return 6 Return -6 End Function To get the rotational range to next angle, simply replace ' Adjust to speed as I don't want the range to next angle :) If (ret <= 0) Return 6 Return -6 with return ret |