sphere arc intersection

421 Views Asked by At

Given:

  • 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!

1

There are 1 best solutions below

0
On

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.