Well, you could replace all the if's with simply the difference between atan(y1,x1)-atan(y2,x2). This is basically what it says in the first post. It will work, if you keep the difference between the angles small enough. However if one angle is 359 and the other 10, it will take the longest route instead of the shortest:
edit: I removed the "Mod 360"'s and it seems to be a bit better
Graphics 800, 600, 0, 2 SetBuffer BackBuffer() ang1# = Rand(360) ang2# = Rand(360) ang2r# = ang2# Repeat ;draw angles Cls Origin 400, 300 ;red=angle1 Color 255, 0, 0 x1# = Cos(ang1) * 120 y1# = Sin(ang1) * 120 Line 0, 0, x1, y1 Text x1 * 1.2, y1 * 1.2, ang1, 1, 1 ;aqua=angle2 Color 0, 255, 255 x2# = Cos(ang2) * 120 y2# = Sin(ang2) * 120 Line 0, 0, x2, y2 Text x2 * 1.2, y2 * 1.2, ang2, 1, 1 Origin 0, 0 ;----------------------------------------------------------------------------- ;calculate angles from coordinates Color 255, 255, 255 angle1# = ATan2(y1, x1); + 360) Mod 360 angle2# = ATan2(y2, x2); + 360) Mod 360 ;calculate differences angdif# = (angle2 - angle1) ;----------------------------------------------------------------------------- ;show difference Text 0, 100, "difference= " + angdif# ;show usage Text 0, 0, "usage:" Text 0, 20, "use cursor keys to move angle1, use space to apply difference" ;cursor keys = move angle 1 If KeyDown(203) Then ang1 = ang1 - 1 If KeyDown(205) Then ang1 = ang1 + 1 ;automove with space If KeyHit(57) Then ang2r# = angle2 - angdif End If If ang2r <> ang2 Then ang2 = ang2 + Sgn(ang2r - ang2) Flip Until KeyHit(1) WaitKey() End
edit: I removed the "Mod 360"'s and it seems to be a bit better