Results 1 to 3 of 3

Thread: Latitudes & longitudes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 1999
    Location
    Ikaalinen, Finland
    Posts
    26

    Question

    Hi there,

    A little bit math also... How it would be possible to find out the distance and magnetic course between two different points on the globe? The latitude & longitude of the points is known. I have been looking for a free OCX or code strip for this, but haven't found any. So does anyone have any idea how this kind of function could be carried out?

    Thanks,
    - Ville
    ......................
    Ville Mattila

  2. #2
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    have u tried researching science books or on the internet to see how you would go about coding it?

    i'm sure there must a site that talks about something like that ...

    i wonder is NASA can be emailed?

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The latitude and longitude -> distance problem got my attention, it's easy if you know how to do it.

    First you need both positions, the latitude and longitude angles gives you this:

    X1=R*cos(lat1)*cos(long1)
    Y1=R*cos(lat1)*sin(long1)
    Z1=R*sin(lat1)
    X2=R*cos(lat2)*cos(long2)
    Y2=R*cos(lat2)*sin(long2)
    Z2=R*sin(lat2)

    the distance d between them is easy pythagoras:

    D = sqr((X1 -X2)^2 + (Y1-Y2)^2 + (Z1-Z2)^2)

    Now the distance is the secant of a circle projection in the sphere, whereas you don't want that distance but the arc that is the distance on the surface of the sphere.

    You calculate the angle between the points on that projected circle:

    a= arcsin(d/(2*r))

    since you can't do arcsin in vb you have to use arcus tangens instead, looked this up in vb5 help file:
    Arcsin(X) = Atn(X / Sqr(-X * X + 1))

    the arc you want can be calculated easily from the angle and the radius:
    Distance=a*R

    Note that vb trigs are done in radians so you need to convert the inputed longitudes and latitudes to radians:
    rad=deg/180*3.1415
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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