Results 1 to 7 of 7

Thread: [RESOLVED] Sin and Cos

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Sin and Cos

    I have problem,

    I have 3 textbox for input degree, minutes and Second.

    I want to calculate the 'dipat' and 'latit'. How to input the degree minutes and second from the textbox into the Sin and Cos?

    Code:
    Dim jarak As Double
    Dim Degree As Integer
    Dim Min As Integer
    Dim Sec As Integer
    Dim latit As Double
    Dim dipat As Double
    
    
    Degree = Val(Text1.Text)
    Min = Val(Text2.Text)
    Sec = Val(Text3.Text)
    jarak = Val(Text4.Text)
    
    dipat = jarak * Sin(Degree, Min, Sec)
    latit = jarak * Cos(Degree, Min, Sec)

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Sin and Cos

    Sin and Cos take an angle(in radians) as input. So you have to compute your angle(degrees) out of "Degree", "Min" and "Sec", convert it to a Radian and then use it in Sin or Cos

    BTW A whole cirlce in Degree in 360° in Radians 2*Pi
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Sin and Cos

    Matrick

    Building on Opus's post, you'll need to define Pi.

    From MSDN
    To convert degrees to radians, multiply degrees by pi/180.
    You might find that using 3.1415927 is sufficiently
    accurate for your purposes. If so, then you can then
    use the built-in Sin and Cos functions as follows
    Code:
    nPI = 3.1415927
    nDeg = Degree + Min / 60 + Sec / 3600
    nRad = nDeg * (nPI / 180)
    '
    dipat = jarak * Sin(nRad)
    latit = jarak * Cos(nRad)
    Spoo

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Sin and Cos

    Just curiosity: are you trying to get azimuth/distance from some given points on earth?

  5. #5
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Sin and Cos

    Quote Originally Posted by Spoo View Post
    You might find that using 3.1415927 is sufficiently
    accurate for your purposes.
    If it's not then: PI = 4 * Atn(1) is a reasonable approximation

  6. #6
    Member
    Join Date
    Jan 2012
    Posts
    58

    Re: Sin and Cos

    Try This:

    PI = 3.14159265358979
    TRIG = PI / 180

    AD = Val(Text1.Text)
    AM = Val(Text2.Text)
    ASEC = Val(Text3.Text)
    Jarak=Val(text4.text)

    L = AD + AM / 60 + ASEC / 3600
    dipat=jarak*sin(L)*trig

    Best Regards
    Sunil

  7. #7
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Sin and Cos

    Note that Pi (the ratio of the circumference of a circle to its diameter) can be approximated very accurately by just dividing 355 by 113. For most applications, that works very well. One has to wonder why we learned 22/7 in grammar school, when 355/113 was always available and far more accurate. Any ideas why 22/7 is still being taught?

    On the other hand, I've been using Doogle's VB6 solution for years.
    Doctor Ed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width