PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Converting the sine of an angle to degrees, minutes, and seconds

 
 
JungleJim74
Guest
Posts: n/a
 
      13th Jul 2009
I am using VS2003 Professional and am trying to display the other two angles
of a right triangle in degrees, minutes, and seconds. This is easy enough to
do with my desktop calculator but I am having difficulty doing it in DOTNET
code. I find the sine of an angle as .6157548327167 which is the sine of an
angle a little over 38 degrees. How do I get this to 38 degrees ? minutes ?
seconds? Thanks in advance for any help and have a good day.
--
JungleJim74
 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      13th Jul 2009
It happens that JungleJim74 formulated :
> I am using VS2003 Professional and am trying to display the other two angles
> of a right triangle in degrees, minutes, and seconds. This is easy enough to
> do with my desktop calculator but I am having difficulty doing it in DOTNET
> code. I find the sine of an angle as .6157548327167 which is the sine of an
> angle a little over 38 degrees. How do I get this to 38 degrees ? minutes ?
> seconds? Thanks in advance for any help and have a good day.


To go from the sine of an angle to it's value, use the Math.Asin()
method. This will return a value in radians. Note: there is also a
Math.Acos() method that starts with the cosine.
There are "pi" radians in 180 degrees, so you will have to divide the
answer by Math.PI and multiply by 180.
There is no built-in method that displays this number in degress,
minutes and seconds so you will have to calculate that yourself.
The Math.Truncate() method could help here.

For more methods, see
http://msdn.microsoft.com/en-us/libr...stem.math.aspx

Hans Kesting


 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      13th Jul 2009
JungleJim74 wrote:
> I am using VS2003 Professional and am trying to display the other two
> angles of a right triangle in degrees, minutes, and seconds. This is
> easy enough to do with my desktop calculator but I am having
> difficulty doing it in DOTNET code. I find the sine of an angle as
> .6157548327167 which is the sine of an angle a little over 38
> degrees. How do I get this to 38 degrees ? minutes ? seconds?


Use Math.Asin to get the angle in radians and then use google to find the
conversion.

http://www.freevbcode.com/ShowCode.asp?ID=8179

Andrew


 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      13th Jul 2009
Andrew Morton wrote:
> Use Math.Asin to get the angle in radians and then use google to find
> the conversion.
>
> http://www.freevbcode.com/ShowCode.asp?ID=8179


Or if you were using a later version of VS, you could do the conversion like

Dim a As Double = Math.Asin(0.06316308504476903) * 180.0 / Math.PI
Dim d As Double = Math.Truncate(a)
Dim t As New TimeSpan(CLng((a - d) * 36000000000.0))
Console.WriteLine("{0} {1} {2}", d, t.Minutes, t.Seconds) ' ->3 37 17

Watch out for negative angles.

Andrew


 
Reply With Quote
 
JungleJim74
Guest
Posts: n/a
 
      13th Jul 2009
Thank you so much but when I try to use the Function that is shown when I
click on your link I get an error in my compiler
C:\MyDotNet\DecimalDegreesToDMS\Form1.vb(197): 'Truncate' is not a member of
'System.Math'.
"How do I eliminate this compiler error? TIA
--
JungleJim74


"Andrew Morton" wrote:

> Andrew Morton wrote:
> > Use Math.Asin to get the angle in radians and then use google to find
> > the conversion.
> >
> > http://www.freevbcode.com/ShowCode.asp?ID=8179

>
> Or if you were using a later version of VS, you could do the conversion like
>
> Dim a As Double = Math.Asin(0.06316308504476903) * 180.0 / Math.PI
> Dim d As Double = Math.Truncate(a)
> Dim t As New TimeSpan(CLng((a - d) * 36000000000.0))
> Console.WriteLine("{0} {1} {2}", d, t.Minutes, t.Seconds) ' ->3 37 17
>
> Watch out for negative angles.
>
> Andrew
>
>
>

 
Reply With Quote
 
Family Tree Mike
Guest
Posts: n/a
 
      13th Jul 2009
JungleJim74 wrote:
> Thank you so much but when I try to use the Function that is shown when I
> click on your link I get an error in my compiler
> C:\MyDotNet\DecimalDegreesToDMS\Form1.vb(197): 'Truncate' is not a member of
> 'System.Math'.
> "How do I eliminate this compiler error? TIA


What version of VS are you using?

--
Mike
 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      13th Jul 2009
"JungleJim74"wrote
> Thank you so much but when I try to use the Function that is shown when I
> click on your link I get an error in my compiler
> C:\MyDotNet\DecimalDegreesToDMS\Form1.vb(197): 'Truncate' is not a member
> of
> 'System.Math'.
> "How do I eliminate this compiler error? TIA


Oh! Math.Truncate appears to not be in .NET 1.1.

Did you know you can get a free version of Visual Basic 2008 Express?
http://www.microsoft.com/express/vb/Default.aspx

Otherwise, you can define

Function truncate(ByVal x As Double) As Integer
If Math.Sign(x) >= 0 Then
Return Math.Floor(x)
Else
Return Math.Ceiling(x)
End If
End Function

HTH

Andrew

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Decimal Degrees to Degrees/Minutes/Seconds Larry_Klotz Microsoft Excel Worksheet Functions 1 2nd Nov 2009 07:22 PM
Converting Degrees/Minutes/Seconds to Decimal Degrees ankud1@yahoo.com Microsoft Excel Programming 6 12th May 2007 05:28 PM
converting decimal degrees to degrees, minutes, seconds =?Utf-8?B?RGF2ZU4=?= Microsoft Access VBA Modules 3 26th Jul 2005 10:21 PM
convert an angle to degrees minutes seconds =?Utf-8?B?TWFj?= Microsoft Excel Misc 1 22nd Mar 2005 03:44 AM
enter an angle in degrees minutes seconds (dms) into spreadsheet =?Utf-8?B?aGFydHI=?= Microsoft Excel Worksheet Functions 1 12th Aug 2004 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:40 AM.