Posted: 4th Mar 2004 21:38
This function will work the same way is the DB built-in function. Just for those who like to know how things work.

+ Code Snippet
function atanful(x#, y#)

  angle# = 90 - atan(y#/x#)
  if x# = 0
      if y# < 0 then angle# = 180
      if y# > 0 then angle# = 0
  endif

  if x# < 0 then angle# = 180 + angle#

endfunction angle#



modified version
+ Code Snippet
function atanful(x#, y#)
    if x# < 0
        angle# = 180 + angle#
        exitfunction angle#
    endif
    
    if x# = 0
        if y# < 0 then angle# = 180
        if y# > 0 then angle# = 0
        exitfunction angle#
    endif
  
    angle# = 90 - atan(y#/x#)
    
endfunction angle#
Posted: 4th Mar 2004 22:54
thats great!

also, isent there a way to use tan() and cos() to get an angle value?
Posted: 5th Mar 2004 1:54
the two distances (x,y) you specify are the legs of a triangle. You could figure out the length of the hypotneuse and use sine or cosine, but its not needed. Tangent is used to find the angle given two legs. Atan to get the angle of that tangent value.
Posted: 5th Mar 2004 20:44
Nice, usefull snippet! I know this was probably only to show how it works, but if with the way you have it written, if x# does equal zero, your going to get a divide by zero error. I'd re-write it like this:

+ Code Snippet
function atanful(x#, y#)

If x <> 0 
 angle# = 90 - atan(y#/x#)
Else
   if y# < 0 then angle# = 180
   if y# > 0 then angle# = 0
endif

if x# < 0 then angle# = 180 + angle#

endfunction angle#
Posted: 6th Mar 2004 4:50
That's odd. That never occurred to me. I know I've tested it x=0 I'm sure, and I got no error.
Posted: 7th Mar 2004 0:41
maybe cause in some cases floats just don't zero...

hey wolf theres a # missing there...