Inverse Tangent in degrees

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Inverse Tangent in degrees

Post by andrewferguson » Sun May 25, 2014 3:34 pm

Hello,
I am trying to find a function that returns the inverse tangent of an angle in degrees.
I am currently using the following function for the "normal" tangent:

Code: Select all

function tanInDegrees angleInDegrees
   return tan(angleInDegrees * pi / 180)
end tanInDegrees
but I have now come across a situation where I need the inverse of tan. Does anyone know of a solution to this problem?

Thanks in advance for any help,
Andrew

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Inverse Tangent in degrees

Post by Dixie » Sun May 25, 2014 4:06 pm

atan, is what you need as it is an inverse of the tan function. The result is returned in radians, so to return the result in degrees...

Code: Select all

  function atanInDegrees theNumber
     return atan(theNumber) * 180 / pi
  end atanInDegrees

andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Re: Inverse Tangent in degrees

Post by andrewferguson » Sun May 25, 2014 4:13 pm

Thank you Dixie, for solving this!
Your help is much appreciated.

Andrew

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Inverse Tangent in degrees

Post by dunbarx » Tue May 27, 2014 3:31 am

Figuring I knew what I was talking about, I was going to say "And here is a good opportunity to use the dictionary to its fullest extent. Check out the "see also..." portion under, say, "tan", a word which you might have found yourself.

But unlike most entries, which usually do have a richly populated list of related words, all the trig function "see also's" are impoverished. Why, the "atan" function does not even mention the "atan2" function, which might be just the ticket for someone trying to find the angle in quadrant three.

This was disconcerting indeed. Good thing I looked first. I think "sin" should at least mention "asin".

Craig Newman

Post Reply