diff options
| author | bsimon <bsimon@stsci.edu> | 2015-04-03 16:08:07 -0400 |
|---|---|---|
| committer | bsimon <bsimon@stsci.edu> | 2015-04-03 16:08:07 -0400 |
| commit | 457db3570a50cf2d88fa5ac00d1ba1d5b119ea7a (patch) | |
| tree | 38f64ab12082bd02976eb288c7650b33312dd304 /stsci/sphere/great_circle_arc.py | |
| parent | 761ea7356c47cefe8b6f7afb2433dc74ec370837 (diff) | |
| download | stsci.sphere-457db3570a50cf2d88fa5ac00d1ba1d5b119ea7a.tar.gz | |
Back ported changes from astropy and made python 2 to 3 modifications
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@38800 fe389314-cf27-0410-b35b-8c050e845b92
Former-commit-id: c12c8fef5503caab2e2e57caac8f040597326589
Diffstat (limited to 'stsci/sphere/great_circle_arc.py')
| -rw-r--r-- | stsci/sphere/great_circle_arc.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/stsci/sphere/great_circle_arc.py b/stsci/sphere/great_circle_arc.py index 0b47d89..e8d421b 100644 --- a/stsci/sphere/great_circle_arc.py +++ b/stsci/sphere/great_circle_arc.py @@ -59,7 +59,7 @@ else: from numpy.core.umath_tests import inner1d -___all__ = ['angle', 'intersection', 'intersects', 'intersects_point', +__all__ = ['angle', 'intersection', 'intersects', 'intersects_point', 'length', 'midpoint', 'interpolate'] @@ -285,9 +285,6 @@ def intersects_point(A, B, C): """ Returns True if point C is along the great circle arc *AB*. """ - if HAS_C_UFUNCS: - return math_util.intersects_point(A, B, C) - total_length = length(A, B) left_length = length(A, C) right_length = length(C, B) @@ -301,8 +298,6 @@ def angle(A, B, C, degrees=True): """ Returns the angle at *B* between *AB* and *BC*. - This always returns the shortest angle < π. - Parameters ---------- A, B, C : (*x*, *y*, *z*) triples or Nx3 arrays of triples @@ -333,8 +328,12 @@ def angle(A, B, C, degrees=True): ABX = _cross_and_normalize(B, ABX) BCX = _fast_cross(C, B) BCX = _cross_and_normalize(B, BCX) + X = _cross_and_normalize(ABX, BCX) + diff = inner1d(B, X) + inner = inner1d(ABX, BCX) with np.errstate(invalid='ignore'): - angle = np.arccos(inner1d(ABX, BCX)) + angle = np.arccos(inner) + angle = np.where(diff < 0.0, (2.0 * np.pi) - angle, angle) if degrees: angle = np.rad2deg(angle) @@ -392,7 +391,7 @@ def interpolate(A, B, steps=50): \frac{\sin((1 - t)\Omega)}{\sin \Omega}A + \frac{\sin(t \Omega)}{\sin \Omega}B """ - steps = max(steps, 2) + steps = int(max(steps, 2)) t = np.linspace(0.0, 1.0, steps, endpoint=True).reshape((steps, 1)) omega = length(A, B, degrees=False) |
