Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The angle sin returns a negative result for the acute angle

Tags:

c#

math

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.

like image 579
Silny ToJa Avatar asked Oct 24 '19 08:10

Silny ToJa


Video Answer


1 Answers

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;
like image 93
haldo Avatar answered Sep 18 '22 01:09

haldo