944,198 Members | Top Members by Rank

Ad:
  • C# Code Snippet
  • Views: 6837
  • C# RSS
0

Degrees to Radians

by on Jun 16th, 2008
The .Net Framework uses by default radians in its trigonometry calculations. Find out how to convert degrees to radians to use with C#
C# Code Snippet (Toggle Plain Text)
  1. private double DegreeToRadian(double angle)
  2. {
  3. return Math.PI * angle / 180.0;
  4. }
  5.  
  6. //Get the Cosine of a 45 degree angle
  7. double angle = Math.Cos(DegreeToRadian(45));
Comments on this Code Snippet
Nov 21st, 2008
0

Re: Degrees to Radians

What about 45°30'10''?
Angles don't always come in whole parts.
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Nov 22nd, 2008
0

Re: Degrees to Radians

If the angle isn't whole use a decimal point (45.352343). If you want to convert something like 45°30'10'' to a decimal representation then that would be a different function to write.
Junior Poster in Training
vckicks is offline Offline
58 posts
since Jun 2008
Message:
Previous Thread in C# Forum Timeline: sql
Next Thread in C# Forum Timeline: Class ToString method not showing properly in Form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC