Given two latitude and longitude points, the bearing with respect to north of a great-circle path starting at each point, and the distance between the two points, how can I calculate the latitude and longitude of the intersection of the two paths if it exists?

  • $\begingroup$ If you are given the latitudes and longitudes of two points, you can calculate the distance between them (it doesn't have to be given). But what is the "bearing with respect to north" of a point at a given latitude and longitude? If that was actually the bearing from one point to another, again you can calculate it from the latitudes and longitudes. Now you ask about an intersection: what is it the intersection of? $\endgroup$ – David K Sep 20 '16 at 20:04
  • $\begingroup$ Its true that I can calculate the distance (already have), Basically I am given two coordinates and the direction they are "pointing" and need to calculate the coordinate that they intersect. The "bearing" that I am talking about would be the look angle. $\endgroup$ – Methalous Sep 20 '16 at 20:09
  • $\begingroup$ I found an online tool that shows what I am trying to do. geocachingtoolbox.com/… I am writing a program to do something similar to option A "Two coordinates with both a bearing with respect to the North." $\endgroup$ – Methalous Sep 20 '16 at 20:12
  • $\begingroup$ I edited the question to try to reflect what the online tool does. If you don't like the changes you can roll back the edit, but I hope what I did expresses what you want to ask. $\endgroup$ – David K Sep 20 '16 at 20:38
  • $\begingroup$ That looks correct. I'm not really sure what "great circle path" as I am just a programmer thrown into the subject with no background. So I will assume its the distance traveled at a constant altitude. $\endgroup$ – Methalous Sep 20 '16 at 20:45

There is a standard formula for this problem on the Aviation Formulary web page. There are also many other useful formulas on that page.

Now to consider various special cases.

One special case is when the two points are the same. Then the bearing (also known as a course angle) from one point to the other is not well defined. Since the bearing is used in the general algorithm for the intersection, we can't use that algorithm. But the obvious intersection point is the same as the starting point(s).

If either point is at the north or south pole, every path from it has the same bearing from North, so the bearing doesn't actually tell you which path is taken from that point. This special case has to be treated as an error, I think, except perhaps if one point if the north pole and the other is the south pole (in which case you might choose either one as "the" intersection).

The remaining special cases are for two points not the same, neither one at a pole.

If the starting points are antipodes of each other, that is, diametrically opposite each other on the Earth, then each of the paths reaches the other point after traveling half way around the Earth. For example, the point $20$N $30$E is the antipodes of $20$S $150$W. If the initial bearings of the two paths add up to any whole multiple of $\pi$ radians ($180$ degrees), then the two paths travel along the same great circle and there are infinitely many points of intersection. If you must pick one, it could be one of the two starting points or one of the two points midway between them; you could decide by considering the initial bearings at each point.

If the points are not antipodes, it is still possible that the paths from the two points travel along exactly the same great circle. For example, if the two starting points are $20$N $10$E and $40$N $10$E, and both start with bearing $0$ degrees from North, then both paths travel the same great circle in the same direction. Using the same two starting points, if one path starts out at bearing $0$ degrees and the other starts with bearing $180$ degrees, they will travel the same great circle in opposite directions. In either case, the path from each point goes through the other point and eventually circles around the Earth to arrive at its starting point.

One way to tell if the paths travel the same great circle is to look at the bearing or course angle from each point to the other point. If the direction from point $A$ to point $B$ is the same as the given bearing of the path starting at $A$, then that path will pass through both points. If the direction from $A$ to $B$ is exactly opposite the given bearing (a difference of $\pm\pi$ radians or $\pm180$ degrees), the path will still go through both points; you just have to go more than half way around the Earth to reach the other point.

You can write a function to decide whether the given path from $A$ passes through $B$. You can then use the same function to decide whether the path from $B$ passes through $A$. If both paths pass through the other point then they are both on the same great circle. Technically, any point is equally "the" intersection point, so you just need to pick one that makes sense to you: the first point, the second point, a point midway between them, or even the antipodes of the midway point. The choice could depend on whether the initial bearing at each point is directly toward or away from the other point.

In any other case, the paths will intersect in exactly two points. The two intersections are antipodes of each other. If the initial bearings at both points are toward the same point of intersection, I would choose that point as "the" intersection. (The intersection might be up to halfway around the Earth from either starting point.)

But it is possible that each path's initial bearing is toward a different one of the two points of intersection. Then you have to come up with some criteria for picking one point or the other, depending possibly on which point is closer to which intersection. In the application for which I needed this algorithm, this case should not have come up normally, so I arbitrarily decided that "the" intersection point would be the intersection that was first reached by the first path.

| cite | improve this answer | |
  • $\begingroup$ Do you know if this formula uses degrees or radians? $\endgroup$ – Methalous Sep 20 '16 at 21:01
  • $\begingroup$ It assumes all angles are in radians. (It also assumes your sin, cos, asin, acos, and atan2 functions all use radians, which is what they do in most software libraries.) $\endgroup$ – David K Sep 20 '16 at 21:19
  • $\begingroup$ I haven't noticed where units of distance apply to that particular set of formulas. The idea is you put in six numbers measured in radians and you get back two numbers measured in radians (latitude and longitude of the intersection point). $\endgroup$ – David K Sep 20 '16 at 21:21
  • $\begingroup$ I have it working now, but I'm worried about the infinite and ambiguous intersections. How can I compute the first point of contact in either case? For example in the infinite if one is pointing up and the other down, I want the first point they overlap. $\endgroup$ – Methalous Sep 21 '16 at 18:21
  • $\begingroup$ The "infinite" and "ambiguous" cases come down to what looks "right" to the user. I've added to the answer what I know about the special cases of path intersections. $\endgroup$ – David K Sep 22 '16 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.