What is the opposite of the Math.tan(double x) function of java?
I know that Tan(X) = oppositeSideLength/AdjacentSideLength
but I have the opposite and adjacent sides so I want to do the opposite operation.
ie: x = Tan^-1(oppositeSideLenght/AdjacentSideLength) (that is how I would enter it in a calculator.
I just looked in the Math class and I know that there is:
Math.atan(Math.atan2
but I don’t think that either of these is what I am looking for.
Yes, you do indeed want atan, or sometimes, atan2. The difference between the two is that atan will fail under some circumstances when one of the side lengths are zero. While that may be unlikely for triangles, it is a possibility for some other, more general uses of atan. In addition, the atan function gives you an angle limited to the interval [-pi/2,pi/2]. So if you think about the atan function as a function of two inputs, (x,y), atan(y/x) will yield the same result as atan((-y)/(-x)). This is a serious flaw in some circumstances.
To solve these problems, the atan2 is defined such that it yields the correct result for all values of x and y, in any quadrant. One would use it as
to yield a consistent result.
Of course, for use in a non-degenerate triangle, the simple call to atan(opposite/adjacent) should be entirely adequate for your purposes.