I calculate the angles of a triangle, and I don't understand why I get a negative angle for some acute angle. For example:
var sin = Math.Sin(4.45);
var radians = Math.Atan(sin);
var angle = radians * (180 / Math.PI);
it return sin = -0.965 and angle = -44.
When scientific calculator show sin = 0.0775
My triangle has such lengths 6.22, 6.07 and 1.4 then there isn't option to had negative angle.
Math.Sin operates on radians. You need to convert degrees into radians.
To convert degrees to radians multiply the angle by 𝜋/180:
var sin = Math.Sin(4.45*Math.PI/180);
// output 0.07758909147106598
And the rest of your code should remain the same.
Note: if you just want to convert an angle in degrees to angle in radians you can use the formula above:
var degrees = 4.45;
var radians = degrees * Math.PI/180;
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