Reputation: 1459
I don't know if I have a fundamental misunderstanding of sine, cosine and tangent or I have a misunderstanding of some of the Math class methods or I'm missing something else but I'm little confused.
I have a right triangle ABC with B = 90 degrees. AB is vertical, BC is flat and AC is the hypotenuse. The length value for AB = 125 and AC = 150. I want to find the value of angle A.
I first try to find the cosine and then I want to convert the cosine to degrees.
double AB = 125;
double AC = 150;
double angleA = Math.cos(AB / AC);
double angleADegrees = Math.toDegrees(angleA);
println(angleADegrees);
The program as it's written returns 57.295. If i try it on my calculator I get a different answer. If I calculate on my calculator to find the cosine = 125/150 i get .8333. Cos^-1(.83333) = 33.5573. The strange thing 57 + 33 + 90 = 180. My program above somehow fnids the value for angle C instead of angle A. Am i calculating for cosine wrong or am I misusing the methods from Math class? I don't know why my program does not return 33 which is what I believe to be the value of angle A.
Upvotes: 3
Views: 18100
Reputation: 476503
You can convert radians into degrees by multiplying it with 180/Math.PI
, Furthermore the inverse cosine (or cos^-1 like some textbooks denote this) is the Math.acos
method (a
standing for arc
).
thus
double AB = 125;
double AC = 150;
double angleA = Math.acos(AB / AC);
println(angleA*180.0d/Math.PI);
will solve the problem.
In case you want to find angle C
, you can calculate this by coding:
double angleCDeg = 90.0d-angleA*180.0d/Math.PI;//angle in degrees.
double angleC = angleC*Math.PI/180.0d;//angle in radians.
Upvotes: 5
Reputation: 65466
mathematically:
cos A = AB/AC
so cos A = 125 / 150
==>
A = cos ^-1 ( 125 /150)
So from (http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Math.html)
double angleRad = Math.acos( AB / AC)
and
double angleDegrees = angleRad * (180 / Math.PI)
Upvotes: 1