0
$\begingroup$

So I'm writing a program and I need to write a method that will give me the angle of a specific angle of a triangle when I know only the adjacent length and opposite length. I know that $\tan(A) = \frac{\text{opposite side}}{\text{adjacent side}}$ but how would I solve for $A$ in that equation?

  • 0
    Never have been taught that in school, thank you very much!2012-01-13

2 Answers 2

1

In terms of software, you have two options: you can search for a trig library that will make inverse tan available as a function/method or you can construct a look-up table. A look up table could be a two-dimensional array with angles from 0 to 180 in one column and corresponding inverse tan values in the other column.

  • 0
    A look-up table will be cumbersome if the input angles are allowed to be non-integers.2012-01-13
0

Basically, as George Watts said, you're looking for the inverse tangent function. Depending on what programming language, that's probably a function called atan or arctan or some variant of that.

As you said you're working in a right triangle, the angle you're looking for is $0<\theta<\frac{\pi}{2}$ (it's most likely that the function in your programming language will give an answer in radians, not in degrees) and $\tan\theta=\frac{\text{opposite leg}}{\text{adjacent leg}}\;\;\Leftrightarrow\;\;\theta=\arctan\left(\frac{\text{opposite leg}}{\text{adjacent leg}}\right).$

Note that if you're not exactly trying to find an acute angle in a right triangle (e.g. if you're trying to find the angle of inclination of a line), you might be better off with the 2-argument arctan function (often atan2) or some other technique.