views:

4191

answers:

3

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?

+3  A: 

There should be an atan() function.

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

Gamecat
+1  A: 

use atan()

chris
+4  A: 

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...

rmeador