# Intersection points between a circle and a straight line on a sphere

I have a circle on the surface of a sphere. I need to check whether the circle intersects with a given straight line or not. The center of the circle $$c$$ is given in terms of latitude and longitude $$(\phi, \lambda)$$, and the radius $$r$$ is given in meters. The latitude and longitudes of two endpoints of the straight line are given $$(\phi_{p}, \lambda_{p}), (\phi_{q}, \lambda_{q})$$.

I assume $$t$$ is a point on $$pq$$ such that $$ct$$ is the shortest distance from $$c$$ to $$pq$$. In the following scenarios intersections are possible. In all other cases no intersection will happen.

$$\Vert cp \Vert \geq r, \Vert cq \Vert \geq r, \Vert ct \Vert \leq r\Rightarrow 2\;\text{intersections}$$ $$\Vert cp \Vert < r, \Vert cq \Vert \geq r, \Vert ct \Vert \leq r\Rightarrow 1\;\text{intersections}$$ $$\Vert cp \Vert \geq r, \Vert cq \Vert < r, \Vert ct \Vert \leq r\Rightarrow 1\;\text{intersections}$$

In the first case I assume the two intersection points are $$x, y$$. The point near $$p$$ is $$x$$, and the point near $$q$$ is $$y$$. We already know $$\Vert pq \Vert$$. Using the Law of Cosines we can derive $$\Vert xt \Vert$$, thus $$\Vert pq \Vert = \Vert pt \Vert - \Vert xt \Vert$$.

$$\Vert xt \Vert = \cos^{-1}\Big(\frac{\cos(r)}{\cos(\Vert ct \Vert)}\Big)$$

But after this I am loosing track. I understand that both $$x, y$$ are in the great circle constructed by $$p, q$$. But I don't know how to determine the latitude and longitudes of $$x$$ and $$y$$ from this information. I targeted the first case assuming solving this will solve the other two cases. My actual problem is to know all the intersection points.

• Your title says ON a sphere. Am I to assume the "on" refers only to the intersection points and the circle and not the "straight line" or is the "straight line" a great circle? – fleablood Dec 21 '18 at 17:27
• The straight line is on a great circle. Like the straight line and the circle are drawn on the ground with a chalk. – Neel Basu Dec 21 '18 at 17:28
• HINT: A stereo-graphic projection is useful as it maps circles to circles. A great circle and and a segment of another great circle $pq$ are given. When the latter segment is extended around the sphere there will be two points of intersection. There would be $(0,1,2 )$ number of projections depending on where the projected arc of circle starts and where mapped length of segment $p^{'} q^{'}$ compared to $2 \pi r^{'}$ ends.. – Narasimham Dec 21 '18 at 19:01
• Sorry, I am not accustomed to these type of math. I need to plot those intersection points on a map based User Interface. – Neel Basu Dec 22 '18 at 6:43