I have a Latitude, Longitude, and a direction of travel in degrees true north. I would like to calculate if I will intersect a line defined by two more Lat/Lon points.
I figure the two points defining the line would create my great circle and my location and azimuth would define my Rhumb line.
I am only interested in intersections that will occur with a few hundred kilometers so I do not need every possible solution.
I have no idea where to begin.
The simple answer is yes -- if you start from any lat/lon and continue traveling along some great circle, you will eventually cross any and all other great circles on the earth. Every two great circles on earth cross each other in exactly two points (with the notable exception of two identical great circles, which, well, cross each other in all their points.)
But I guess you are not merely asking a yes/no question. You may be wondering where, exactly, those two great circles intersect. We can use the following strategy to find that out:
Each great circle lies on a plane that goes through the center of the earth.
The intersection of those planes is a line (assuming they are not both the exact same plane.)
That intersecting line crosses the surface of the earth at two points -- exactly where our two great circles intersect.
Our mission is thus: (1) find the planes. (2) find their intersection line. (3) find the two intersection points, and finally, (4) express those intersection points in terms of lat/long. (5) extra credit for figuring out which intersecting point is closer to the lat/lon you started at.
Sounds good? The following does this with trig and vector math. To simplify the math somewhat, we'll:
- work with the unit sphere, the one centered at the origin of our (x,y,z) coordinate system, and has a radius of 1: x^2+y^2+z^2=1.
- we'll assume the earth is a perfect sphere. Not a geoid. Not even a flattened sphere.
- we'll ignore elevation.
Step 1 -- find the planes:
All we really care about is the plane normals. Here's how we go and find them:
--One great circle is defined by two points on the earth that it crosses
The normal will be the cross product of the (x,y,z) vectors of each point from the origin (0,0,0). Given the lat/lon of each point, using spherical coordinates conversion, the corresponding (x,y,z) are:
x=cos(lat)*sin(lon)
y=cos(lat)*cos(lon)
z=sin(lat)
With that, and our two points given as lat1/lon1 and lat2/lon2, we can find out the vectors P1=(x1,y1,z1) and P2=(x2,y2,z2).
The first great circle normal is then the cross product:
N1=P1 x P2
--The other great circle is defined by a point on the earth and an azimuth
We have a point P3 and an azimuth T. We'll find a point P4 along the great circle going through P3 at azimuth T at a distance of PI/4 by using the spherical law of cosines (also solved for our convenience here):
lat4=asin(cos(lat3)*cos(T))
lon4=lon3+atan2(sin(T)*cos(lat3),-sin(lat3)*sin(lat4))
Then the normal is as before:
N2=P3 x P4
Step 2: find the planes intersecting line:
Given the two plane normals, their cross product defines their intersecting line:
L=N1 x N2
Step 3: find the intersection points:
Just normalize the vector L to get one of the intersection points on the unit sphere. The other point is on the opposite side of the sphere:
X1=L/|L|
X2=-X1
Step 4: express the intersection points in terms of lat/lon:
Given X=(x,y,z), using spherical coordinate conversion again, and taking into account the point is on the unit sphere:
lat=asin(z)
lon=atan2(y,x)
Step 5: which of the two points is closer?
Use the haversine formula to figure out the distance from your point to X1 and X2, choose the nearer one.
I think your best bet is to use stereographic projection to map the problem from the sphere to the plane. This projection is very useful in that it maps your rhumb line to a logarithmic spiral of form R=exp(θa) (aka a loxodrome) and maps your great circle to a circle on the plane. So your problem reduces to finding the intersection of a logarithmic spiral and a circle (after which you map back to the sphere).
This is just a sketch to get you started. If you need more details, just ask.