How to write an ATan2( ) function?

Blitz3D Forums/Blitz3D Programming/How to write an ATan2( ) function?

I think it would be something along these lines:

ATan2() would take two parameters (y#, x#) and return the arctangent of y/x. The way I understand it, it's a "quadrant-specific" version of arctangent...

If x = 0 And y = 0 Then Return FAIL
If x = 0 And y > 0 Then Return 90
If x = 0 And y < 0 Then Return -90
If x > 0 And y = 0 Then Return 0
If x > 0 And y <> 0 Then Return ATan(y/x)
If x < 0 And y = 0 Then Return 180
If x < 0 And y <> 0 Then Return (180 - ATan(Abs(y) / Abs(x))) * Sgn(Y)

Test that out (and optimize it) before you use it.

<EDIT> Whoops, that's what I get for waiting to reply...