Thank you for your help.
I guess what I'm seeing and what I keep running into problems with, is the direction angles open. The atan() function calculates angles starting from the positive horizontal and increases as the angle opens counter clockwise.
The atanfull() function calculates angles starting from the positive vertical and increases as the angle opens clockwise. Your example function also calculates clockwise starting from positive vertical.
Maybe I'm missing something, but using any of the inverse trig functions gives back the counter clockwise angle, and using atanfull gives back the clockwise angle. Here's an example:
`**************************************
`* Title : Inverse Trig Functions vs atanfull()
`* Author : Latch
`* Date : 9/5/06
`* Version:
`**************************************
set display mode 800,600,16
print "In a right triangle, angle theta is unknown."
print "Also the Hypotenuse is unknown."
print "We know that the opposite side to theta = 2."
print "We know the adjacent side of theta = 3."
print "Using SOHCAHTOA we can find theta."
print "Using the Pythagorean Theorem, we can find the"
print "Hypotenuse."
print "Let a# be opposite to theta"
print "Let b# be adjacent to theta"
print "Let c# be the hypotenuse."
print "Let theta# be theta."
Print "-------------------------------------------------"
rem -----Hypotenuse
print "Hypotenuse Using Pythagorean Theorum"
a#=2
b#=3
c#=sqrt((a#^2)+(b#^2))
print "c#=sqrt((a#^2)+(b#^2)) c#= ";c#
print
rem -----Theta using atan()
Print "Theta Using Tangent"
toa#=a#/b#
theta#=atan(toa#)
print "tan(theta#)=a#/b# atan(a#/b#)= theta# = ";theta#
print
rem ----Theta using asin()
print "Theta Using Sine"
soh#=a#/c#
theta#=asin(soh#)
print "sin(theta#)=a#/c# asin(a#/c#)= theta# = ";theta#
print
rem ----Theta using acos()
print "Theta Using Cosine"
cah#=b#/c#
theta#=acos(cah#)
print "cos(theta#)=b#/c# acos(b#/c#)= theta# = ";theta#
print
rem ----Theta using atanfull()
print "Theta Using atanfull() function"
theta#=atanfull(b#,a#)
print "Using atanfull(x#,y#) we subsitiute b# for x# and a# for y# = ";theta#
Thanks in advance for any help.
[Edit]
I think I got it. I've been reviewing the library function atan2(y,x) and believe DarkBASIC's equivalent is atanfull(). In C, atan2() takes the y input before the x input. When I use this method in DBC, I get the angles I expect - opening counter clockwise and matching the other inverse trig functions.
Though the DBC manual states:
ATANFULL()
This command will return the angle of two points in degrees between 0 and 360. The distance values are calculated by finding the distance between two points for both the X and Y axis. The distance values can be a real or integer number. The return value should be a real number.
SYNTAX
Return Value=ATANFULL(Distance X, Distance Y)
I will use Return Value=ATANFULL(Distance Y, Distance X). Any opinions on this?
Enjoy your day.