Windows Vista Forums

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

  1. #1


    JungleJim74 Guest

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

    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

      My System SpecsSystem Spec

  2. #2


    Hans Kesting Guest

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

    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



      My System SpecsSystem Spec

  3. #3


    Andrew Morton Guest

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

    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



      My System SpecsSystem Spec

  4. #4


    JungleJim74 Guest

    Re: Converting the sine of an angle to degrees, minutes, and secon

    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
    >
    >
    >

      My System SpecsSystem Spec

  5. #5


    Family Tree Mike Guest

    Re: Converting the sine of an angle to degrees, minutes, and secon

    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

      My System SpecsSystem Spec

  6. #6


    Andrew Morton Guest

    Re: Converting the sine of an angle to degrees, minutes, and secon

    "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


      My System SpecsSystem Spec

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

Similar Threads
Thread Forum
Convert # of second in Days / Hours / Minutes / Seconds
I had a vbscript doing this for me, I was thinking converting this function to PS, but I wonder if a build-in .NET which I can call with PS was...
PowerShell
How do I get from the sine of an angle to the actual angle
I have been struggling with this for several days but have been unable to do it. I have downloaded and installed the VB Express Edition 2008 so that...
.NET General
WLM 9 Beta - Video freezing for 5-10 seconds every few minutes
I'm experiencing video freezing for 5-10 seconds or so every few minutes when in video calls with people. What can be the reason? WLM, my Logitech...
Live Messenger
Vista randomly freezes every few minutes for about 2-4 seconds
I have a relatively new laptop (few months old) with vista home premium 64 bit...and starting yesterday it has been freezing every 10 minutes or so...
Vista performance & maintenance
Vista Upgrade - Takes 30 Seconds to 5 minutes after mouse "click"
My system was auto upgraded on shutdown last night. This morning, the system booted fine. However, clicking on anything with the mouse results in...
Vista General
Dell 24" viewing angle
I am considering a Dell 2407wfp monitor for general use, gaming, photoshop etc. Everything seems OK except that the technical spec indicates a poor...
Vista hardware & devices
Is there a way to control the angle of a lineargradient?
I have added a lineargradient to a rectangle. I have specified the direction of the gradient as StartPoint=0,0 to EndPoint=1,1. When I change the...
Avalon