Hi J,Yes, it is ok.
I tested x, y = 0,1... 1,0....0,-1 and - 1, - 1 all correct.
0,1 gives 360. If needed could add:
if atn >= 360 then
atn = atn-360
Is it ok to change 'b' to 'bdeg'? There's another 'b' in the program.
Here's what I've tried, but it didn't work. Does it look ok?
C.
'VVVVVVVVVVVVVVVVVVVVVVVVVVVV DEGREE CALC VVVVVVVVVVVVVVVVVVVVV
'Result in degrees clockwise from North = 0
Function atn(x_c As Single, y_c As Single) As Single
If y_c = 0 Then
y_c = y_c + 0.000001 'to prevent divide by zero
Endif
tang = x_c / y_c
at1 = 90 * tang * (bdeg + tang) / (1 + 2 * bdeg * tang + tang * tang)
at2 = -90 * tang * (bdeg - tang) / (1 - 2 * bdeg * tang + tang * tang)
If x_c >= 0 Then
If y_c > 0 Then
atn = at1
Endif
Endif
If x_c >= 0 Then
If y_c < 0 Then
atn = 180 - at2
Endif
Endif
If x_c < 0 Then
If y_c < 0 Then
atn = 180 + at1
Endif
Endif
If y_c > 0 Then
If x_c <= 0 Then
atn = 360 - at2 'atn2 ?????????????????
Endif
Endif
End Function
'AAAAAAAAAAAAAAAAAAAAAAAAAAAA DEGREE CALC AAAAAAAAAAAAAAAAA