Search code examples
javadegrees

java, How to calculate degree from tan


I'm using java. I have a tan value. I really surprise that I can't find a way to turn it into degree. I already search but only find a way to turn degree into tan. please help.


Solution

  • The function you're looking for is double atan(double tangent) which, given the tangent, will return the angle in radians.

    From there, you can simply multiply it by 180 / PI to get degrees or, better yet, use the inbuilt double toDegrees(double radians).

    In other words, something like (assuming you've bought in java.lang.Math):

    double degs = toDegrees(atan(tangent));