Returns the angle from the X axis to a point (y,x). |
(yvalue,xvalue) |
Command Description:
Aside from its basic trig usage, this nifty command will allow you to derive an angle based on the x and y speed of a travelling object. |
Example:
; Atan2 example ; Set graphics w/double buffering Graphics 640,480,16,0 SetBuffer BackBuffer() ; Starting point for our travelling box x=0 y=0 ; random speed values for travelling xSpeed=Rand(5) ySpeed=Rand(5) ; repeat until the ESC or box travels off the screen While Not KeyHit(1) Or y > 480 Or x > 640 Cls ; Draw our box Rect x,y,10,10,1 ; increment the box location based on random speed x=x+xSpeed y=y+yspeed ; print the angle of our box travel Text 0,0,ATan2(yspeed,xspeed) Flip Wend |