Confusion with Math.toDegrees() and Math.toRadians(). Please help.
Dear administrators and members,
A greeting of peace.
I hope everyone is in good health upon reading this thread.
I am currently working on a simple program that uses trigonometric laws like sine laws. I first try to write this simple codes first:
Code :
double angle = 60;
System.out.println( Math.sin(Math.toDegrees(angle) );
Then the output is: 0.7475(something)
I wonder why the output is 0.7475(something)? BUT, when I tried pressing sin 60 on my scientific calculator (in degrees mode as usual) the answer is 0.8660(something).
Then later, I tried to use toRadians() method in Math class:
Code :
double angle = 60;
System.out.println( Math.sin(Math.toRadians(angle) );
Then that is the time I got the 0.8660 (something) answer.
I am just a little confused. My scientific calculator is in degrees mode, that is why I am expecting the same result if I will use the toDegrees() method, but why it did not?
Please enlighten me. Did I miss something?
Respectfully Yours,
MarkSquall
Re: Confusion with Math.toDegrees() and Math.toRadians(). Please help.
Hi,
for Math.sin(doulbe a), a is an angle, in radians (pls refer to in API document), that's why sin(Math.toRadians(angle)) works.
Re: Confusion with Math.toDegrees() and Math.toRadians(). Please help.
one more thing, following words are from API document, FYI.
about toDegrees, "The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0. "
Re: Confusion with Math.toDegrees() and Math.toRadians(). Please help.
Dear Ms. ivy,
I already read the Java API documentation, and it's a great help for some useful definition. BUT, I just wondered why toRadians() is the one gave me the correct answer (as the one in my scientific calculator) than toDegrees() .
Is it not if I press sin 60 in my scientific calculator, 60 is already (or "converted") in degrees (since my calculator is in DEG mode)?
But anyway, a million thank you and more power. :cool:
Warm regards,
MarkSquall