Determine Direction to Rotate based on 2 Angles
BlitzMax Forums/BlitzMax Programming/Determine Direction to Rotate based on 2 Angles
| ||
| Ok, my math skills are not the greatest... If I have two Angle A1 and A2, I need to determine which direction to rotate (Clockwise or Counter Clockwise) to get from A1 to A2 the fastest. Any help would be greatly appreciated! Brien King |
| ||
| Brien, Try this:
' return -1 to -180, or 1 to 180
Function TurnToFace:Int(A1#, A2#)
Local ret:Int
ret = A1-A2
If ret >= 180
ret = -(360 - ret)
Else
If ret <= -180
ret = ret + 360
EndIf
EndIf
Return ret
End Function
|
| ||
| Works great! Thanks for the help! |