Welcome to Dream.In.Code
Become a VB Expert!

Join 137,231 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,832 people online right now. Registration is fast and FREE... Join Now!




Calculating distance using Latitude/Longitude

 
Reply to this topicStart new topic

Calculating distance using Latitude/Longitude

aNiXtEr
8 Feb, 2007 - 07:01 PM
Post #1

New D.I.C Head
Group Icon

Joined: 8 Feb, 2007
Posts: 25


My Contributions
Here is the project I have been working on in VB.NET Class:
Great Circle Navigation

Do the necessary Internet research to find the equations that calculate the distance from one point on the Earth to another point given that the earth is round. Write a function that accepts coordinates in Longitude and Latitude and returns the distance.

On the internet find the locaton of several zip codes in coordinates to test. Document.

Download and install google earth (http://earth.google.com). Notice that the mouse pointer can be used to find the coordinates of a location. Test. You might try your house location, etc. Try to determine to accuracy (resolution) of Google Earth - document.

I am having trouble with the formula especially:
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))

any suggestions???
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Calculating Distance Using Latitude/Longitude
8 Feb, 2007 - 07:09 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
What seems to be the problem you are having with the forumula?

Converting it to something you can do in code?

You can do that by using Math.Sin, Math.Acos, Math.Cos.
CODE

d = Math.Acos(Math.Sin(lat1) * Math.Sin(lat2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Cos(lon1 - lon2))

User is offlineProfile CardPM
+Quote Post

aNiXtEr
RE: Calculating Distance Using Latitude/Longitude
8 Feb, 2007 - 09:04 PM
Post #3

New D.I.C Head
Group Icon

Joined: 8 Feb, 2007
Posts: 25


My Contributions
QUOTE(jayman9 @ 8 Feb, 2007 - 08:09 PM) *

What seems to be the problem you are having with the forumula?

Converting it to something you can do in code?

You can do that by using Math.Sin, Math.Acos, Math.Cos.
CODE

d = Math.Acos(Math.Sin(lat1) * Math.Sin(lat2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Cos(lon1 - lon2))



You have magical powers. Well sort of. The actual formula isn't hard. It was hard for me to grasp calculating the formula. But what i did, for those who are reading was to convert the degrees/mins to radians then put the decimal result into the formula then solve. Easy to solve, hard to start. Thanks for your help.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:27PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month