Distance Calculator

Discussion in 'Share Your Creations' started by PatrikL, Apr 29, 2007.

  1. PatrikL

    PatrikL Member Licensed User

    This sub is usable in GPS programs -
    Code:
    Sub Calc
    result.Text = 
    sqrt(69.1 * (Lat2.Text - Lat1.Text) * 69.1 * (Lat2.Text - Lat1.Text) + 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3) * 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3))
    End Sub
    (Source: http://www.meridianworlddata.com/Distance-Calculation.asp )
    - create 5x TextBox - Lat1,2; Lon1,2; result and one Button - Calc
    My sample is here:
    [​IMG]
     

    Attached Files:

    Last edited: Apr 29, 2007
  2. sho431

    sho431 New Member

    Hi PatrikL

    very good sample, but what about the direction.
    :)

    Thanks
    shooshan
     
  3. PatrikL

    PatrikL Member Licensed User

    Good idea, i try to find formula via google :)
     
  4. sho431

    sho431 New Member

    I need :sign0085:

    Code:
    distanceEast=(Lon2.Text - Lon1.Text) 
    distanceNorth=(Lat2.Text - Lat1.Text)
    direction= 
    Atan(distanceNorth/distanceEast) Mod (2 * cPI)
    direction = (direction)*(
    180/cPI)
    If direction < 0 Then
    direction+= 
    360
      
    End If
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    There is no += in Basic4ppc.
     
  6. PatrikL

    PatrikL Member Licensed User

    2 sho431
    - i try repair that sub, but it don't work :sign0085:
    From where is that formula?
     
  7. sho431

    sho431 New Member

    Hi

    :sign0013:

    From this
    Code:
    http://www.tma.dk/gps/#calcdir
     
  8. PatrikL

    PatrikL Member Licensed User

    Thanks, i will look at it. ;)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice