From d038dab0595b47e9d897778913967f038f15bedd Mon Sep 17 00:00:00 2001 From: mdroe Date: Fri, 1 Jun 2012 17:44:00 +0000 Subject: Fix drawing -- basemap can not handle drawing great circle arcs that go around the edges of the domain. The solution is to do the interpolation in the quaternion space and then pass little snippets of that to basemap. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/branches/sphere@17192 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: dc807419ae1618c42af6434f6e63c7f0cb3bf36e --- lib/great_circle_arc.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/great_circle_arc.py') diff --git a/lib/great_circle_arc.py b/lib/great_circle_arc.py index 056857d..93d9ad2 100644 --- a/lib/great_circle_arc.py +++ b/lib/great_circle_arc.py @@ -315,3 +315,26 @@ def midpoint(A, B): l = np.sqrt(np.sum(P * P, axis=-1)) l = np.expand_dims(l, 2) return P / l + + +def interpolate(A, B, steps=50): + """ + Interpolate along the great circle arc. + + Parameters + ---------- + A, B : (*x*, *y*, *z*) triples or Nx3 arrays of triples + The endpoints of the great circle arc. It is assumed that + these points are already normalized. + + steps : int + The number of interpolation steps + + Returns + ------- + array : (*x*, *y*, *z*) triples + The points interpolated along the great circle arc + """ + t = np.linspace(0, 1.0, steps, endpoint=True).reshape((steps, 1)) + + return (t * A) + ((1.0 - t) * B) -- cgit