For this answer I will not rely on Cartesian coordinates, but I will not work directly in terms of latitude and longitude either. Instead, it will be convenient to represent a point with spherical coordinates $(\phi,\theta)$ as $z=e^{i\phi}\tan\dfrac\theta2$, corresponding to a stereographic projection of the sphere into the complex plane. We can now apply Mobius transformations to move the complex numbers $\alpha$, $\beta$ (corresponding to $A$, $B$) to more helpful locations.
Specifically, we can use rotations to move $\alpha$ to zero, then map $\beta$ to the real line, and finally rotate $\{\alpha,\beta\}$ to $\{r,r^{-1}\}$ on the positive real line. This amounts to rotating our coordinates so that $A$ and $B$ have zero longitude and opposite latitudes. To make this simpler, we shall assume that $\alpha$ is real without loss of generality (i.e. we take the longitude of $B$ relative to $A$).
We now state these transforms explicitly. First, note that the subgroup of the Mobius group corresponding to rotations consists of mappings of the form $z\mapsto \dfrac{u z-\overline{v}}{v z+\overline{u}}$ for complex $u,v$. A mapping of this form which takes $\alpha$ to the origin is $z\mapsto \dfrac{z-\alpha}{\alpha z+1}$; this also maps $\beta\mapsto \dfrac{\beta-\alpha}{1+\beta\alpha}= R e^{i\psi}$ for some real $R,\psi$. A rotation $z\mapsto e^{-i\phi} z$ then brings $\beta$ to $R$.
For the last transformation, consider the mapping $z\mapsto \dfrac{1+z r}{r-z}$ for real $r>0$ which takes the real line to itself. Then $\{0,R\}\mapsto \left\{\dfrac{1}{r},\dfrac{1+r R}{r-R}\right\}$; since we want the images of $0$ and $R$ to be on equal and opposite sides of the 'equator', we require their product to be unity. From this we deduce $r=R+\sqrt{1+R^2}$. Composing the three transformation gives the net rotation
$$\mathcal{T}:\;z
\mapsto \dfrac{z-\alpha}{1+\beta\alpha}
\mapsto e^{i\phi}\left(\frac{z-\alpha}{1+\beta\alpha}\right)
\mapsto \dfrac{1+e^{i\phi}\left(\frac{z-\alpha}{1+\beta\alpha}\right)r}{r-e^{i\phi}\left(\frac{z-\alpha}{1+\beta\alpha}\right)}
=\dfrac{e^{-i\phi}(1+\beta\alpha)+(z-\alpha)r}{r e^{-i\phi}(1+\beta\alpha)-(z-\alpha)}$$
We now can give a criterion for the original question: a point $z$ lies between $\alpha$ and $\beta$ if $r^{-1}\leq | \mathcal{T}(z)|r$. In principle one can do inverse transformations to map this annulus back to the original coordinates, but I won't do so explicitly. Instead I'll just summarize the result:
Let $\alpha,\beta$ be the stereographic coordinates of two points $A,B$ on the unit sphere, and define $w=R e^{i\phi}:=\dfrac{\beta-\alpha}{1+\beta\alpha}$. Then a point $C$ on the unit sphere lies between $A$ and $B$ iff its sterographic coordinate $z$ satisfies
$$\frac{1}{r}< \left|\dfrac{e^{-i\phi}(1+\beta\alpha)+(z-\alpha)r}{r e^{-i\phi}(1+\beta\alpha)-(z-\alpha)}\right|<r$$ where $r=R+\sqrt{1+R^2}$.
You want to draw a line form $A$ to $B$. With the following method you can find the middle point of this line, $M$. Repeating this method wou will be able to find points in the desired line as close as you want for your initial points, and this is enough to draw the line.
With a ruler and a compass you can draw lines of the length that you want. First of all we will draw a line passing from A and enough close to B. In order to do this do the following:
- Draw two lines starting at A more or less close to B, say $l_1$ and $l_2$, and let $\alpha$ be the angle between them.
- If $B$ is located between the lines, OK. If not, draw a fan of lines forming an angle $\alpha$ with the previous ones until you get two lines for which $B$ is located betwwen them.
- Now we have two lines starting at $A$ and with $B$ located "inside". Let $l_3$ be the bisectrix.
- Repeat the step 3 enough times choosing each time lines such that the point $B$ is "inside".
After this process we get a line $l$ passing through $A$ as close as we want to $B$. Since $B$ and $l$ are enough close we can draw with our small ruler and our small compass an orthogonal line to $l$ passing through $B$. So we have a right triangle with vertex on $A$ and $B$ and edges $l$ and $r$. Transporting angles from $B$ to $A$ you can draw a rectangle with vertex $A$, $E$, $B$ and $F$. This rectangle have the property that its height (length of the segment $AE$) is enough small and its diagonal is $AB$ is the desired line.
Now, using additional lines we are able to find the middle points of the long sides. Let $E_1$ be the middle point of $AE$ and $F_1$ the middle point of $BF$.
Since $E_1$ and $F_1$ are enugh close one from the other, we can determine the point $M$ in the middle of them, and this point belongs to the desired line $AB$.
Iterating this algorithm you can draw the line.
I hope that the you can understand my poor explanation...sorry about my english!
Best Answer
What the OP really wants, I think, is a crossing number algorithm for a simple closed continuous curve. Such a curve can be considered, however, as the limiting case of a simple polygon, for its edges becoming infinitesimally small. A relevant reference therefore may be this Wikipedia one:
-
Point in polygon
and especially the crossing number algorithm.But there is much more to tell about the Inside / Outside Problem, once you take a good look at it.
After some (in vain) attempts to answer the question in a concise manner, and while making too many duplicates of existing material, I've decided to simply redirect to my best shot so far:
-
Inside / Outside Problem
If the points of the simple closed curve are considered as pixels (i.e. integer coordinates), then we can even devise a never fail algorithm (only assuming that our picture is not too large).It is seen in the picture below that, for a continuous curve, simple and straightforward application of the crossing number algorithm will be OK for the points $A$ and $B$, but it certainly will go wrong for the points $C$ and $D$. According to Murphy's law , Anything that can go wrong will go wrong. Meaning that ignoring special cases, especially in a computational geometry environment, sooner or later, will be disastrous. It is noticed that the "wrong" cases have to do with rays that are tangent to the curve.