intersection¶
- spherical_geometry.great_circle_arc.intersection(A, B, C, D)[source]¶
Returns the point of intersection between two great circle arcs. The arcs are defined between the points AB and CD. Either A and B or C and D may be arrays of points, but not both.
- Parameters:
- A, B(x, y, z) triples or Nx3 arrays of triples
Endpoints of the first great circle arc.
- C, D(x, y, z) triples or Nx3 arrays of triples
Endpoints of the second great circle arc.
- Returns:
- T(x, y, z) triples or Nx3 arrays of triples
If the given arcs intersect, the intersection is returned. If the arcs do not intersect, the triple is set to all NaNs.
Notes
The basic intersection is computed using linear algebra as follows [1]:
\[T = \lVert(A × B) × (C × D)\rVert\]To determine the correct sign (i.e. hemisphere) of the intersection, the following four values are computed:
\[ \begin{align}\begin{aligned}s_1 = ((A × B) × A) \cdot T\\s_2 = (B × (A × B)) \cdot T\\s_3 = ((C × D) × C) \cdot T\\s_4 = (D × (C × D)) \cdot T\end{aligned}\end{align} \]For \(s_n\), if all positive \(T\) is returned as-is. If all negative, \(T\) is multiplied by \(-1\). Otherwise the intersection does not exist and is undefined.
References
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276271