gsm icon     interpolating    mapping    searching geospatial methods

Spheres: Great Circle Intersections.


Great Circle intersects Great Circle: Any two points on a sphere uniquely define a great circle (so long as they are not antipodal). Given two points (lat1, lon1), (lat2, lon2) the great circle that contains these two points is defined by points (latc, lonc) that satisfy:

latc= atan((sin(lat1)*cos(lat2)*sin(lonc - lon2) - sin(lat2)*cos(lat1)*sin(lonc - lon1)) / (cos(lat1)*cos(lat2)*sin(lon1 - lon2)))

Any two Great Circles intersect exactly twice.  So given four points defining two great circles we seek the two points at which those great circles intersect.  Two equations and two unknowns, it should be simple.  But if we do it on the sphere it involves spherical trig, and spherical trig involves a lot of trig.  That is:

Given:

latc= atan((sin(lat1)*cos(lat2)*sin(lonc - lon2) - sin(lat2)*cos(lat1)*sin(lonc - lon1)) / (cos(lat1)*cos(lat2)*sin(lon1 - lon2) ) )

and

latc= atan((sin(lat3)*cos(lat4)*sin(lonc - lon4) - sin(lat4)*cos(lat3)*sin(lonc - lon3)) / (cos(lat3)*cos(lat4)*sin(lon3 - lon4)))

Solve for (latc, lonc)

Here is one solution for lonc.  This is one fourth of the complete solution:

lonc = -ArcCos[ -Sqrt( b2 f2 Cos[lon1]2 - 2abf2 Cos[lon1] Cos[lon2] + a2f2 Cos[lon2]2 - 2bcef Cos[lon1] Cos[lon3] + 2acef Cos[lon2] Cos[lon3] + c2e2 Cos[lon3]2 + 2bcdf Cos[lon1] Cos[lon4] - 2acdf Cos[lon2] Cos[lon4] - 2c2de Cos[lon3] Cos[lon4] + c2d2 Cos[lon4]2)/ Sqrt( b2f2 Cos[lon1]2 - 2abf2 Cos[lon1] Cos[lon2] + a2f2 Cos[lon2]2 - 2bcef Cos[lon1] Cos[lon3] + 2acef Cos[lon2] Cos[lon3] + c2e2 Cos[lon3]2 + 2bcdf Cos[lon1] Cos[lon4] - 2acdf Cos[lon2] Cos[lon4] - 2c2de Cos[lon3] Cos[lon4] + c2d2 Cos[lon4]2 + b2f2 Sin[lon1]2 - 2abf2 Sin[lon1] Sin[lon2] + a2f2 Sin[lon2]2 - 2bcef Sin[lon1] Sin[lon3] + 2acef Sin[lon2] Sin[lon3] + c2e2 Sin[lon3]2 + 2bcdf Sin[lon1] Sin[lon4] - 2acdf Sin[lon2] Sin[lon4] - 2c2de Sin[lon3] Sin[lon4] + c2d2 Sin[lon4]2)]

It is much easier in Cartesian space.  While any two non antipodal points on a sphere define a great circle any three non colinear points in space define a plane.  The two points that define the great circle, combined with the origin, can be used to uniquely define the plane that contains that great circle.  So given two planes we can find the line defined by the intersection of those planes, and then find the two points where the line intersects the sphere.  It's a lot more steps, but a lot less trig and, overall, a lot less math.

Given two planes (that contain the origin) and a sphere:

(y0z1- y1z0)x - (x0z1- x1z0)y + (x0y1- x1y0)z = 0

(y2z3 - y3z2 )x - (x2z3 - x3z2 )y + (x2y3 - x3y2)z = 0

x2+ y2+ z2= r2

Solve for (x, y, z)

The algorithm used by the spheres package is as follows:

  1. Define the constants in the planar equations. 

    1. Let a = (y0z1 - y1z0 )
      Let b = -(x0z1 - x1z0 )
      Let c = (x0y1 - x1y0 )
      Let d = (y2z3 - y3z2 )
      Let e = -(x2z3 - x3z2 )
      Let f =  (x2y 3 - x3y 2)

      So the planar equations simplify to:
      ax + by + cz = 0
      dx + ey + fz = 0

  2. Solve for x:

    1. ax + by + cz = 0 so
      x = (-by - cz) / a

  3. Solve for y:

    1. dx + ey + fz = 0
      d(((-by - cz) / a)) + ey + fz = 0
      (-dby/a) - (dcz/a) + ey + fz = 0
      ey - (dby/a) = (dcz/a) - fz
      y(e-(db/a)) = z((dc/a) - f)
      y((ea - db)/a) = z((dc-fa)/a)
      y = z * ((dc-fa)/a) * (a/(ea-db))
      y = z * ((dc-fa)/(ea-db))

      Let h = (dc-fa)/(ea-db) so y = hz


  4. Get x in terms of z:
    1. x = (-by - cz)/a
      x = (-bhz - cz)/a
      x = z * ((-bh - c)/a)

      Let g = ((-bh - c)/a) so x = gz


  5. Solve for z:
    1. x2+ y2+ z2= r2
      (gz)2+ (hz)2+ z2= r2
      z2(g2+ h2+ 1) = r2
      z2= r2/(g2+ h2+ 1)
      z = +- sqrt(r2/(g2+ h2+ 1))

  6. Find the intersects:
    1. Let k = sqrt(r2/(g2+ h2+ 1))

      The two great circles intersect at the points: (gk, hk, k) and (-gk, -hk, -k)

      Convert those points back to spherical coordinates

      latC= ArcSin(k/r)
      lonC= ArcTan(hk/gk)
      or
      latC= ArcSin(-k/r)
      lonC= ArcTan(-hk/-gk)

Great Circle intersects Latitude:   The equation for the plane that intersects the sphere at a given latitude is: z = z0where z0 = r*sin(lat0).  Finding the points where a great circle intersects a parallel is just a variation of the method above.

Given two planes and a sphere:

(y0z1 - y1z0)x - (x0z1 - x1z0)y + (x0y1 - x1y0)z = 0

z = z2

x2+ y2+ z2= r2

Solve for (x, y, z)

The algorithm used by the spheres package is as follows:

  1. Define the constants in the planar equations. 

    1. Let a = (y0z1 - y1z0)
      Let b = -(x0z1 - x1z0)
      Let c = (x0y1 - x1y0 )
      So ax + by + cz = 0

  2. Solve for x:
    1. z = z2 and ax + by + cz = 0 so
      x = (-by - cz2) / a

  3. Solve for y:
    1. x2+ y2+ z2= r2
      ((-by - cz2) / a)2 + y2+ z22 = r2
      ((b2y2+2bycz2 +c2z22) / a2) + y2+z22 = r2
      y2((b2+ a2) / a2) + y(2bcz2/ a2) = r2- z22 - ((c2z22) / a2 )
      y2 + 2y(bcz2/ a2) * (a2/(b2+ a2)) = (r2- z22 - ((c2z22) / a2 )) * (a2/(b2+ a2))

      It's getting messy so
      Let d = (bcz2/ a2) * (a2/(b2+ a2)) = (bcz2)/(b2+ a2)
      Let rhs = (r2- z22 - ((c2z22) / a2 )) * (a2/(b2+ a2))
      Let e = sqrt(rhs + d2)
      so e2 = rhs + d2
      so e2 - d2 = rhs

      then y2+ 2dy = e2 - d2

      Complete the square
      y2+ 2dy + d2 - d2 = e2 - d2
      (y + d)2- d2= e2- d2
      (y + d)2= e2- d2+ d2
      (y + d) = +- e
      y = -d +- e


  4. Find the intersects:
    1. The great circle and the parallel intersect at the points:

      ((bd - be -cz2) / a, -d + e, z2)  and   ((bd + be - cz2) / a, -d - e, z2)

      Convert those back to spherical coordinates.

      latC= ArcSin(z2 / r)
      lonC= ArcTan((-d + e)/((bd - be -cz2) / a))
      or
      latC= ArcSin(z2 / r)
      lonC= ArcTan((-d - e)/((bd + be - cz2) / a))


Great Circle intersects Small Circle:   A small circle is defined as any circle on a sphere that is not a great circle.  

This algorithm is not yet implemented by the spheres package.



| Home | About | FAQ |

Geospatialmethods.org is maintained at the National Snow & Ice Data Center in Boulder, CO.
Please direct questions or comments to NSIDC User Services