I'm using Math.cos
and Math.sin
but it returns me unexpected results like these:
Angle Sin Cos
354 0.8414 -0.5403
352 0.1411 0.98998
350 -0.958 -0.2836
Why I get these results?
In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math. cos() function returns the cosine of value passed as argument. The value passed in this function should be in radians.
The Math. cos() method is used to return the cosine of a number. The Math. cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians.
cos() returns the cosine of a number (radians) that is sent as a parameter.
What is the cosine formula? The cosine formula to find the side of the triangle is given by: c = √[a2 + b2 – 2ab cos C] Where a,b and c are the sides of the triangle.
Are you trying to use degrees? Keep in mind that sin
and cos
are expecting radians.
Math.cos(Math.toRadians(354))
Math.cos
and Math.sin
take angles in radians, not degrees. So you can use:
double angleInDegree = 354;
double angleInRadian = Math.toRadians(angleInDegree);
double cos = Math.cos(angleInRadian); // cos = 0.9945218953682733
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