Calculate the angle

Blitz3D Forums/Blitz3D Programming/Calculate the angle

maverick69(Posted 2005) [#1]
I have a little problem (more of a math than a programming problem :-).

I draw a line using the following code:

Line 320,240,MouseX(),MouseY()


Now I want to calculate the angle of the line, for example if my Mouse Coordinates are (320,100) it should return 0°, if they are (500,240) it should return 90° and so on...

I'm sure someone can help me... ;)


Jeppe Nielsen(Posted 2005) [#2]
You would use Atan2():
angle#=Atan2(Mousey()-240,MouseX()-320)

Try switching the variables if you don't get the right angles.


maverick69(Posted 2005) [#3]
Thank you,

works fine :-)