• an arc defined by two end points (which I can express in lat/lon/altitude or earth-centered fixed (ECF) 3D 'cartesian' space)
  • a sphere defined by a center (lat/lon/alt or ECF) and a radius (expressed in any units, e.g. 100 km)

How can I determine the intersection of the arc and the sphere? I do not care about the tangent case, only the case where the arc enters (and potentially exits) the sphere.

I'm grateful for any replies. I have googled this ad naseum and keep finding lines and ray solutions but no arc-sphere intersection solutions.

Thanks from Florida!

  • $\begingroup$ Is the "arc" straight? $\endgroup$ – Brian Tung Mar 21 '16 at 21:13
  • $\begingroup$ The arc is a great circle line, so it's absolutely not straight. It's really the path an airplane flies between two points (arbitrary altitudes at each end) in my problem domain. I'm trying to find out when the airplane enters and exits airspaces defined by spheres. $\endgroup$ – Jason Mar 22 '16 at 12:45
  • $\begingroup$ Ahh, that would have been useful to know. $\endgroup$ – Brian Tung Mar 22 '16 at 17:24
  • $\begingroup$ Can we assume that the plane begins and ends its path at a constant altitude (say, a cruising altitude of 10 km)? In other words, can we neglect takeoff and landing for the purposes of intersecting airspace? (I assume it is easy to tell that the aircraft exits its origin airspace and enters its destination airspace.) $\endgroup$ – Brian Tung Mar 22 '16 at 17:27
  • $\begingroup$ Thank you for your help @BrianTung! I'm sorry that I wasn't more clear. I should've said the arc is defined by two arbitrary end points. So that means altitude can change from the start to the end point of the arc. If you or anyone does find a closed form solution to this problem I'll be happy to post my JAVA code interpretation of that here for anyone else who comes along. The plane does change altitudes during flight, but it stays very close to a pre-computed path (which is composed of one or more of these arcs). $\endgroup$ – Jason Mar 22 '16 at 17:55

Edit. The following answers a question a little different from what was intended by the OP, but I am leaving it up in case it's helpful for someone wandering in off a search.

Suppose, for the sake of ease of computation and exposition, that the sphere is centered at $(0, 0, 0)$ and has radius $R$, and that the arc is a straight line segment between $(x_0, y_0, z_0)$ and $(x_1, y_1, z_1)$, and we wish to find the intersection point or points of that segment with the sphere.

We parametrize the line segment as

$$ x(t) = (1-t)x_0+tx_1 \qquad y(t) = (1-t)y_0+ty_1 \qquad z(t) = (1-t)z_0+tz_1 $$

for $0 \leq t \leq 1$. Then we are looking for $(x(t), y(t), z(t))$ that has a distance from the origin equal to $R$, for some $t$ in that interval. That is,

$$ [x(t)]^2+[y(t)]^2+[z(t)]^2 = R^2 $$

As all of the coordinates are linear in $t$, we will end up with a quadratic equation in $t$, which can be solved in the usual way. Only those solutions in the interval $t \in [0, 1]$ fall between the endpoints.

For example, suppose we have a sphere of radius $R = 7$, start point $(10, 0, 5)$ and end point $(4, 3, 2)$. Then,

$$ x(t) = 10(1-t)+4 = 10-6t $$ $$ y(t) = 0(1-t)+3t = 3t $$ $$ z(t) = 5(1-t)+2t = 5-3t $$

Then our quadratic equation is

$$ (10-6t)^2+(3t)^2+(5-3t)^2 = 7^2 $$

or, expanded out,

$$ 54t^2−150t+76 = 0 $$

This has the solutions

$$ t_{1, 2} = \frac{75 \pm \sqrt{5625-4104}}{54} = \frac{75 \pm \sqrt{1521}}{54} = \frac{75 \pm 39}{54} = \frac{2}{3}, \frac{19}{9} $$

Only the lesser value $t_1 = \frac{2}{3}$ falls within the interval $[0, 1]$, however, so plugging that back into the original parametric equations yields the point at which the arc enters the sphere:

$$ x(t) = 10-6 \times \frac{2}{3} = 10-4 = 6 $$ $$ y(t) = 3 \times \frac{2}{3} = 2 $$ $$ z(t) = 5-3 \times \frac{2}{3} = 5-2 = 3 $$

That is, at the point $(6, 2, 3)$. The second point is inside the sphere, so the arc does not exit the sphere again.

| cite | improve this answer | |

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.