I have 4 geographic points (latitude, longitude, altitude). By assuming the curvature of the earth, these correspond to two curves. Points A and B make up the end points of the first curve segment. Points C and D make up the end points of the second curve segment.
I want to determine if these two curve segments intersect. I'm assuming the best way to go about this is to convert these four points into Cartesian Coordinates which I've done. But I'm not sure how to solve for the rest. I've seen examples pertaining to two great circles, infinite lines, or line segments. But I haven't been able to put it all together. Anyone have any ideas (or better tags for me)?
A great circle is the intersection of the sphere and a plane through the origin. For two great circles, their planes will intersect in a line passing through the center. The two intersection points of the line with the sphere are also the two intersection points of the two great circles.
The only thing remaining to determine is if one of those intersection points is on the arcs $\overset\frown {AB}$ and $\overset\frown {CD}$ instead of their opposite arcs on the great circle. If $\overset\frown {PQ}$ always refer to the shorter of the two great circle arcs generated by non-antipodal points $P$ and $Q$, then an easy trick is that the plane intersection line will intersect the arc $\overset\frown {PQ}$ if and only if it also intersects the chord $\overline{PQ}$.
So you have points $A, B, C, D$, which you've already converted into cartesian coordinates. You don't say what size sphere you've converted them too, but it will be easiest if it is points on the unit sphere. Treat these points as vectors.
The normal to the plane of the great circle through $A$ and $B$ is $\vec n = A \times B$ - the vector cross-product. The plane itself has equation $\vec n \cdot \vec r = 0$, where $\vec r$ is the position vector. Similarly, let $\vec m = C \times D$. From a mathematical point of view, it doesn't matter, but it might be wise numerically to replace $\vec n$ and $\vec m$ with their normalized versions: $\hat n = \frac{\vec n}{\|\vec n\|}, \hat m = \frac{\vec m}{\|\vec m\|}$.
The line of intersection between these two planes is perpendicular to both normals, which means it must be parallel to their cross-product, so let $\vec v = \hat n \times \hat m$. Again, for numerical stability, it is best to use $\hat v = \frac{\vec v}{\|\vec v\|}$ instead of $\vec v$ itself - though mathematically both will give the same answer. Since this line passes through the origin, it is the set $\{t\hat v\mid t\in \Bbb R\}$.
The line segment from $A$ to $B$ is $\{A + s(B - A)\mid s \in [0,1]\}$.
So to find if they intersect, we need to solve $t\hat v = A + s(B - A)$ for $t$ and $s$. As $A, B, \hat v$ are 3-dimensional vectors, this is a system of three linear equations in the two unknowns $s$ and $t$. This system can have $0, 1$ or infinitely many solutions, though the latter can be discounted, as it would require $A$ and $B$ to be antipodes, which would have failed much earlier. If it has no solution, then the two arcs cannot intersect. If there is a unique solution, then look at the value of $s$: if $s < 0$ or $s > 1$, then the line does not intersect $\overline{AB}$ and $\overset\frown {AB}$, so again there is no intersection between the arcs.
If $s \in [0,1]$, the line intersects $\overset\frown {AB}$. Perform the same calculation for $\overset\frown {CD}$. It that $s \in [0,1]$ as well, the line also intersects $\overset\frown {CD}$ - but it may do so on the opposite side of the sphere from the intersection with $\overset\frown {AB}$. So now compare the two values for $t$ obtained from the $\overset\frown {AB}$ and $\overset\frown {CD}$ calculations. If they are of the same sign, then $\overset\frown {AB}$ and $\overset\frown {CD}$ intersect. If they are of opposite sign, they do not intersect.