I want to give the result the Math.cos() method in java in degrees.I have tried methods like converting from radians to degrees. But I discovered that any number I pass into the Math.cos() method is being treated as radians,irrespective of whether I convert.Please I can I make it give me the result in degrees.Thanks.
use Math.toRadians to convert your degrees to radians to pass to Math.cos for example
double blah = Math.cos(Math.toRadians(50));
I think that is what you are asking. There are quite a lot of similar questions here.
You can use Math.toDegrees()/Math.toRadians()
Converts an angle measured in radians to an approximately equivalent angle measured in degrees/radians.
Note that public static double cos(double a) expect the parameter in radians:
a - an angle, in radians.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With