## Calculate Direction and Distance between 2 points Geometry. Anyone have formulae?

### #1

Posted 19 October 2006 - 12:08 PM

### #2

Posted 19 October 2006 - 12:23 PM

### #4

Posted 19 October 2006 - 12:35 PM

It looks l9ike you're looking for the first two entries in the 'great circle' chapter.

He seems to even have Excel versions on that page.

### #5

Posted 19 October 2006 - 12:38 PM

Here's a little primer I copy/pasted from the Ottawa regional forums (Canada's Capital Cachers):

Quote

What we need is a way to transfer the lat/long coordinates onto a flat grid that we can then use to do the trigonometry. A function that does that is called a map projection; one of the most common is the Universal Transverse Mercator (UTM) projection, and it's built in to your GPS. By selecting UTM as your location format, the GPS will start using UTM coordinates for all its displays. (On my Garmin eMap, I do Setup->Advanced->Location format->UTM UPS).

A UTM coordinate looks something like this:

18 T 0441492 5020648

What does that mean? Well, 18T is the UTM latitude & longitude zone; it basically defines the origin of the coordinate system (there are 60 longitude zones, each divided into 16 latitude zones). As long as all our calculations are in the same zone, we don't need to worry about it. 0441492 is the easting - the number of metres east of the origin - of the point. 5020648 is the northing - the number of metres north of the equator - of the point. So basically, if we ignore the zone, we have two numbers (441492,5020648) that give us (x,y) coordinates on an ordinary cartesian grid.

What can we do with this? Well, for starters, computing the distance between two points is easy: just use the Pythagorean theorem:

dist = sqrt( (x1-x2)^2 + (y1-y2)^2)

So to find the distance from the previous point to, say, 18T 450371 5030346 is a simple calculation:

dist = sqrt( (450371-441492)^2 + (5030346-5020648)^2)

= 13148.7 metres

and the bearing can also be computed using simple trigonometry:

bearing = arctan((5030346-5020648)/(450371-441492))

= 47.5 degrees

Triangles, circles, angles, everything you learned in high school trigonometry will work with UTM coordinates.

### #6

Posted 19 October 2006 - 01:55 PM

naviguesser74, on Oct 20 2006, 06:08 AM, said:

I googled "latitude longitude distance" in advanced search in xls files only. Found THIS. Has everything you need.

### #7

Posted 19 October 2006 - 02:04 PM

Marbig's Woodenheads, on Oct 19 2006, 03:55 PM, said:

naviguesser74, on Oct 20 2006, 06:08 AM, said:

I googled "latitude longitude distance" in advanced search in xls files only. Found THIS. Has everything you need.

Except you can't see the formulas to integrate into your own spreadsheet.....

### #8

Posted 19 October 2006 - 05:32 PM

StarBrand, on Oct 20 2006, 08:04 AM, said:

Marbig's Woodenheads, on Oct 19 2006, 03:55 PM, said:

naviguesser74, on Oct 20 2006, 06:08 AM, said:

I googled "latitude longitude distance" in advanced search in xls files only. Found THIS. Has everything you need.

Except you can't see the formulas to integrate into your own spreadsheet.....

Not quite. The file is not password protected so hidden columns are able to be accessed and formulas seen.

However the file seems to have its own formula functions in there also which would have to be used in your own file. Not sure on how to do this though.

### #9

Posted 19 October 2006 - 05:40 PM

XLS PROGRAM

This post has been edited by **Marbig's Woodenheads**: 19 October 2006 - 05:40 PM

### #10

Posted 19 October 2006 - 07:02 PM

(VBA means Excel can use it)

### #11

Posted 20 October 2006 - 03:23 AM

naviguesser74, on Oct 19 2006, 04:08 PM, said:

Have a look at the "Mileage Spreadsheet" that I have linked on my web site: http://ca.geocities....geocaching.html I think that may be what you are looking for in Excel. I use it all the time to keep track of the caches I have found. It's got all the formulas in the hidden cells.

### #12

Posted 20 October 2006 - 06:00 AM

fizzymagic, on Oct 19 2006, 07:02 PM, said:

(VBA means Excel can use it)

Hey...wanna send that my way? I took some VBA classes in college, and need to get back up-to-speed on it (use ArcView GIS software at work, and it's VBA-based....would like to write some custom code for it) What better way to brush up on the code than by using it in my hobby

### #14

Posted 20 October 2006 - 07:08 AM

### #15

Posted 20 October 2006 - 07:14 AM

naviguesser74, on Oct 19 2006, 03:08 PM, said:

edit: Sorry, Tahosa and Sons - looks like we were typing the same thing at the same time!

This post has been edited by **worldtraveler**: 20 October 2006 - 07:16 AM

### #16

Posted 20 October 2006 - 09:12 AM

http://tech.groups.yahoo.com/group/macmap/...er%20Utilities/

Now I just need to do a similar calculation for direction. Distance to next cache will be so small that I am willing to assume flat surface.

### #17

Posted 20 October 2006 - 09:23 AM

Remember there is NO WWW in this address. Remember there is a colon( between degrees and minutes in the format. To become proficient with this try solving my A. Spring mystery cache (GCWE3D).

I learned of this while doing a cache in Gillam county Oregon called "Cold Bailey"

To solve the distance between the point where you are and a visible but inaccesable object without a GPSr, use your compass. 1. Determine azumith to object. 2. Turn exactly 90 degrees (right or left, easiest path)

3. Count your paces. 4. When the azumith to the inaccesable object is 30 degrees different from the original az. the distance along the base of the triangle is half the height of the triangle. The hypotenuse is the square root of 5.

Tom Fuller

This post has been edited by **tomfuller & Quill**: 20 October 2006 - 09:27 AM

### #18

Posted 20 October 2006 - 02:24 PM

**Waypoint workbench**

Its an excellent free piece of software ( ok its set up for UK geocachers but can be tailored to suit your needs....)

Slainge ....

### #19

Posted 20 October 2006 - 05:16 PM

naviguesser74, on Oct 19 2006, 01:08 PM, said:

Do you want flat world or round world?

### #20

Posted 22 October 2006 - 10:45 AM

### #21

Posted 22 October 2006 - 03:03 PM

### #22

Posted 22 October 2006 - 03:10 PM

### #23

Posted 26 October 2006 - 12:55 PM

This post has been edited by **Don&Betty**: 26 October 2006 - 01:01 PM

### #24

Posted 29 October 2006 - 12:24 PM

Don&Betty, on Oct 26 2006, 12:55 PM, said:

Bearing is =atan(delta North / delta East). This is equivalent to =asin(delta North / r), where r is the radius (or hypoteneus of the triangle) as determined from the quadratic equation as you outline above.

The easiest way to get around the difference in length between minutes of lat and long is to use UTM coordinates, especially when you are in the same UTM grid. Without converting to UTM or making the corrections as Don&Betty describe above you will get erroneous bearing calculations regardless of how close together the origin and destination are.

The problem with using Excel to calculate bearing is that atan/asin report a value between -pi/2 and +pi/2. Therefore you can only determine which compass quadrant you are in by evaluating the delta East and delta North from your chosen origin.

A further complication is that atan/asin will report a value of 0 deg for due east, when on a compass 0 deg is due north.

These problems can be overcome by using a simple lookup table as below:

The first step is to determine the angle using the asin function (asin reports in radians which must be converted to degrees to be useful)

I. r = sqrt((delta North)^2 + (delta East)^2)

II. angle = degrees(asin( r / delta North))

Then check if the destination is west of the origin

III. Wvalue = if(delta East < 0, "A", "") ; if the destination is west of the origin the value will be A, if east then blank

then check if the destination is south of the origin

IV. Svalue = if(delta North < 0,"B", "") ; if the destination is south of the origin the value will be B, if north then blank

Determine the W/S lookup value

V. WSvalue = concatenate(Wvalue, Svalue) ; this just sticks the results from steps III. and IV. together

then lookup the WSvalue in the following table

[indent]90 (destination is in northeast quad)

A [indent]270 (destination is in northwest quad)

AB [indent]270 (destination is in southwest quad)

B [indent]90 (destination is in southeast quad)

using the following formula

VI. compass bearing = vlookup(WSvalue, lookup table range, 2, 0) - (angle from step II.)

Sounds complicated, but it is five formulas plus a 4x2 lookup. Again, the distances must either be from UTm coords or coords adjusted for distance from the equator.

This post has been edited by **DogFleazJR**: 29 October 2006 - 12:31 PM

### #25

Posted 17 November 2006 - 12:37 PM

### #26

Posted 17 November 2006 - 12:47 PM