Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the "reverse" tangent in objective-c?

I know that tan(angle) gets me the tangent. But how do I do the "reverse tangent" so that I can get the angle given the length of both sides of the right triangle?

I'm assuming there is a method for this in math.h?

like image 823
rksprst Avatar asked Oct 28 '08 20:10

rksprst


People also ask

How do you find the inverse tangent in C?

atan() function is used to find the arc tangent of a number means gives a tangent value to this function it will return the angle in radians corresponding to that value. arc tangent is the inverse operation of a tangent.

How do you find the inverse tangent?

In a right-angled triangle, the tangent of an angle (θ) is the ratio of its opposite side to the adjacent side. i.e., tan θ = (opposite side) / (adjacent side). Then by the definition of inverse tan, the inverse tan formula is, θ = tan-1[ (opposite side) / (adjacent side) ] .

How do you write inverse trig functions in C?

C acos() The acos() function returns the arc cosine (inverse cosine) of a number in radians. The acos() function takes a single argument (1 ≥ x ≥ -1), and returns the arc cosine in radians. Mathematically, acos(x) = cos-1(x) .


2 Answers

As others have mentioned, atan() is what you're looking for. Generally, the operation is referred to as "inverse tangent" or "arc tangent", not "reverse tangent". The name "atan" comes from "arc tangent". There's also an atan2() function which takes both the X and the Y coordinates as separate paramters and will give you an angle relative to the 0 mark whereas atan() will leave figuring out the quadrant as an exercise for the developer. Beware, however, that the atan2() function on certain older MS environments (or maybe visual studio libraries?) doesn't work quite right...

like image 136
rmeador Avatar answered Oct 05 '22 22:10

rmeador


There should be an atan() function.

For example: http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.7.html

like image 23
Toon Krijthe Avatar answered Oct 06 '22 00:10

Toon Krijthe