.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C# Trigonometry conversion mistake

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
398 Views, 2 Replies

C# Trigonometry conversion mistake

Hi,

I am trying to evaluate a variable which is related with some trigonometric angles. However The code is leading to some different value that of the hand calculated ones. I was expecting the value of z to be 124... however code is giving some unreasonable value. This might be very silly, but I am sure I have missed some logic. Some one please help me.

 

My code is like this

 

theta = Math.Atan(l1 / l2) * 180 / Math.PI;    // converted to degrees
y = l3 / Math.Cos(theta / 2.0);
z = y * Math.Sin(theta / 2.0);

 

_20161105_140209.JPG

 

2 REPLIES 2
Message 2 of 3
Keith.Brown
in reply to: Anonymous

I believe that the issue is that you are getting an answer from arctan in radians, converting it to degrees to calculate the sin and cosine.  The sin and cos functions take a parameter that is in radians not degrees.

 

Check out the help pages below.

 

atan

cos

sin

Message 3 of 3
Anonymous
in reply to: Keith.Brown

Thank you Keith Brown. Using rad instead of deg works.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report