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
?
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.
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) ] .
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) .
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...
There should be an atan() function.
For example: http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.7.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With