Angle between two XY positions

BlitzMax Forums/BlitzMax Beginners Area/Angle between two XY positions

Why does that work, btw, and why doesn't Atan() regular work for this purpose?
It does. ATan(y/x) should give the same results as ATan2(y,x). But since BlitzMAX doesn't do function overloading... :o>

The "snapping" you're experiencing is because x1 , y1, x2, y2 and by extension ax and yx are integers, when they should be floats! This means that when you divide them inside the ATan call the result is in integer division and a high degree of accuracy loss occurs!

To "fix" it you can either:
a) Make sure your delta values ax and ay are floats, and make sure you use them for the division.
b) Make sure x1,x2,y1 and y2 are all floats and then use the code you have now.