With all my astronomical calculations of late I stumbled over

a beloved problem from my early days in trig class: When taking

the ATAN(x/y) you need to check x and y to find out in which quadrant

the result must come to be.

Has anyone ever built a nice ASM function that would be fast, mean and lean?

This is my implementation (which works, but is kind of clumsy)... or could

I get Tom or Lance to put the ATAN2 function on the wishlist for the compiler?

------------------

Balt

bi at inside dot net

"It's not the end, not even the beginning of the end, but, it might be the end of the beginning!"

[This message has been edited by Balthasar Indermuehle (edited August 19, 2003).]

a beloved problem from my early days in trig class: When taking

the ATAN(x/y) you need to check x and y to find out in which quadrant

the result must come to be.

Has anyone ever built a nice ASM function that would be fast, mean and lean?

This is my implementation (which works, but is kind of clumsy)... or could

I get Tom or Lance to put the ATAN2 function on the wishlist for the compiler?

Code:

'serves to find the correct quadrant when doing an atan(y/x). 'returns raqdians Function ATN2 (Y As Ext, X As Ext) As Ext Dim res As Ext If (X = 0) Then If (Y = 0) Then res = 0 Else res = Sgn(Y) * (Pi/2) End If Else res = Atn(Y / X) If (X < 0) Then If (Y < 0) Then res = res - Pi Else res = res + Pi End If End If End If Function = res End Function

------------------

Balt

bi at inside dot net

"It's not the end, not even the beginning of the end, but, it might be the end of the beginning!"

[This message has been edited by Balthasar Indermuehle (edited August 19, 2003).]

## Comment