4

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.

Phootip
  • 156
  • 1
  • 12

2 Answers2

7

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));
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • atan actually gives the angle as radians, so you have to multiply the result with 180.0 to get the corresponding value in degrees – pnkkr Dec 11 '16 at 12:09
  • 1
    @pnkkr, good point, though it's `180/PI` - have added that to the answer. Thanks. – paxdiablo Dec 11 '16 at 12:11
-3

tan^-1 of value and some more text because it's too short.

TigOldBitties
  • 1,331
  • 9
  • 15
  • 1
    Your *calculator* may have a `tan^-1` button but I don't think Java is similarly belssed :-) – paxdiablo Dec 11 '16 at 12:09
  • You're not searious, are you? That's the notation for the inverse of tangent http://mathworld.wolfram.com/InverseTangent.html also denoted as arctan as you said. – TigOldBitties Dec 11 '16 at 12:12
  • Actually, I *am* serious. The question was about *Java.* While your answer may be educational for other purposes, it's not really that helpful in answering the specific question. – paxdiablo Dec 11 '16 at 12:16
  • You appear to have missed the point. That link is actually quite good if you're wanting to learn trigonometry but it seems a little deficient in actually trying to figure out *how* to get the arctan from Java (other than perhaps providing an extra search term to look for). In any case, I don't see much point in arguing the case, we'll let the swarm decide. – paxdiablo Dec 11 '16 at 12:20