# Calculating Great Circle Distance

1. Feb 4, 2012

### Rapier

1. The problem statement, all variables and given/known data
Find the distance from Atlanta to San Francisco if Atlanta is @ 33.75°N and 84.40°W and San Francisco is @ 37.78°N and 122.42°W. Explain your strategy.

2. Relevant equations
cos phi = z/rho
cos theta = x/r
r = rho*sin phi

3. The attempt at a solution
I believe that latitudes are my thetas and the longitudes are my phis. I've tried to come up with equations that allow me to solve for a single variable but I keep having too many unknowns.

Someone suggested use the difference in theta (and phi) in my equations but even then I am still stuck on how to convert these angle measures into spherical coords.

I am looking for a way to get started, and any help would be greatly appreciated.

2. Feb 4, 2012

### I like Serena

Hi Rapier!

I recommend converting your coordinates to cartesian vectors.
Then you can calculate the angle between them using the dot product.
Since you know you're interested in a great circle, the distance is the arclength of the circle segment between the 2 vectors.

3. Feb 4, 2012

### tiny-tim

Hi Rapier!

Alternatively, if you know your spherical trigonometry,

apply it to the obvious spherical triangle

4. Feb 4, 2012

### Rapier

That is the problem I am having. I am trying to convert the two angle measures to cartesian coords, but I'm running into problems. As much as I massage my equations from my triangles to try and convert the coords, I end up with an extra term I can't solve for (eg three unknowns and two equations). I have a hunch that I should be possibly leaving one of the values as a ratio (eg r/z) but I keep ending up in circles, where I start with cos θ = x/r and after three or four substitutions I have cos θ = x/r.

5. Feb 5, 2012

### I like Serena

If I understand correctly, you don't know how to convert spherical coordinates (r,ϕ,θ) to cartesian coordinates (x,y,z)?
Well, you are using an extra "r" and you are missing an "y", so that might muddy your set of equations...

The conversion from spherical to cartesian is:
x = ρ sin ϕ cos θ
y = ρ sin ϕ sin θ
z = ρ cos ϕ
where ρ is the earth radius, ϕ is the colatitude (90° - latitude), and θ is the longitude.

6. Feb 5, 2012

### Rapier

AH HAH! I got so wrapped up in the math that I forgot that this was an actual problem and not an exercise. The term I was missing was the radius of the earth (ρ). That made all the difference.

Using these definitions (I'm using N and E as positive directions):
SF: θ=33.75°, ϕ=-84.4°
AT: θ=37.78°, ϕ=-122.42°

So now I've converted my terms:
SF = 6.3781e6m <-.8275, -.5529, .0976>
AT = 6.3781e6m <-.6672, -.5171, -.5361>

Looking at my terms, they look real good. I would expect that my vectors from the center of the earth to any point on the surface would be the radius and if I find the magnitude of my vectors they are 1 (well, out to 4 decimal places, so close enough).

Using a sketch, I've determined that D = SF - AT (image attached)
I found my straight line distance between the two points, which is .7875ρ.
The angle between the two vectors (A.S = ||A|| ||S|| cos θ) is 38.215° or .66698 radians.

The arc length is the angle of the arc * radius (technically θ/total degrees in circle * C) .

s = θ * 6.3791e3 km, I used radians (but to make double sure I also used degrees and got the same value)
But I come out with 4254.050 km. I found a Great Circular Calculator online that say the distance between the two cities is 3443.341 km.

I've made an error somewhere. You mentioned a colatitude and I don't know what that is. I am wondering if the angle measures I'm using are not the correct ones. Could you verify that my triangles are using the correct angle measures or help me to understand my error (image attached)?

OR considering the distances, is this an acceptable amount of error?

#### Attached Files:

File size:
10.8 KB
Views:
169
• ###### mms_img72130.jpg
File size:
11.7 KB
Views:
175
Last edited: Feb 5, 2012
7. Feb 5, 2012

### I like Serena

:)

But you have San Francisco at 33.75°N.
This is a latitude, which is the angle relative to the equator.
However, the angle in spherical coordinates is the angle relative to the north pole.
This is called the colatitude.
To find the colatitude, you need to calculate 90° - latitude.

There is internationally some confusion about what should be called theta and what should be called phi in spherical coordinates.
However, in the formulas you've shown, phi corresponds to the colatitude, which is the angle with the north pole.
You've switched the angles around.

To find the distance, you should not calculate the length of the vector, but the arclength of the great circle segment, which is radius times angle.

Btw, what are you using for the earth radius?

8. Feb 5, 2012

### Rapier

STOP! Hold the presses!!

Latitude is measured from the equator north, no? So, I can think of that measure being from the horizontal up. My ϕ measurements are from the vertical down. So I need to use the compliment (which a quick wiki search tells me is the COlatitude).

YES? Let me recalculate and I'll get back to you.

9. Feb 5, 2012

### I like Serena

Yes.

10. Feb 5, 2012

### Rapier

Re = ρ = 6.3781e3 km

Using these definitions (I'm using N and E as positive directions):
SF: θ=56.25°, ϕ=-84.4°
AT: θ=52.22°, ϕ=-122.42°

So now I've converted my terms to cartesian coords:
SF = 6.3781e3 km <-.5529, -.8275, .0976>
AT = 6.3781e3 km <-.5171, -.6672, -.5361>

SF.AT = ||SF|| ||AT|| cos θ
(.2859+.5521-.0523) = (1)(1) cos θ
θ = 38.215° = .66697 radians

s = θ * ρ
s = .66697 radians * 6.3781e3 km
s = 4253.7547 km

I'm still running at 23% error.

11. Feb 5, 2012

### I like Serena

Apparently you've still switched θ and ϕ around.

You can see that your numbers are wrong, since AT has a negative z coordinate, while it's above the equator.

12. Feb 5, 2012

### Rapier

Oh geez louise! I was using (ρ,ϕ,θ) instead of (ρ,θ,ϕ). θ is my longitude (eg prime meridian) and ϕ is my lattitude (eg equator). I had my triangles swapped the whole time. It's always the little things isn't it?

13. Feb 5, 2012

### I like Serena

;)

Do you have the right answer now?

14. Feb 5, 2012

### Rapier

Yes, I got 3435.488 km which is .22% error. That's pretty good! Thanks for all the help!

15. Feb 5, 2012

### tiny-tim

Rapier, do you know the spherical trig formulas?

If not, don't worry; but if you do, then applying them to the appropriate triangle would get you the result rather more easily.

16. Feb 5, 2012

### Rapier

No, I don't. I just looked it up on wikipedia and none of that looks familiar. I took Geometry and Trig in the 1980s and I'm finding that they have really filled in the curriculum in the past 20 years. It's not unusual for me to run into a topic and find that it's something that I never had a chance to learn. Sigh.