From 5f6068fb585a25d9d07800844a0fa23f4b6347c9 Mon Sep 17 00:00:00 2001 From: mdroe Date: Wed, 4 Jun 2014 19:37:32 +0000 Subject: Fix some numerical problems that prevented some very short arcs that were colocated with the edges of a polygon from being recognized as inside the polygon. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@32335 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: df6e3d7c90b358c56d4f84df17b19a742e405337 --- stsci/sphere/polygon.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'stsci/sphere/polygon.py') diff --git a/stsci/sphere/polygon.py b/stsci/sphere/polygon.py index 06f6b80..2d67ff2 100644 --- a/stsci/sphere/polygon.py +++ b/stsci/sphere/polygon.py @@ -498,16 +498,20 @@ class SphericalPolygon(object): Determines if this `SphericalPolygon` intersects or contains the given arc. """ - return self.contains_point(great_circle_arc.midpoint(a, b)) + P = self._points - if self.contains_point(a) and self.contains_point(b): + if self.contains_arc(a, b): return True - P = self._points intersects = great_circle_arc.intersects(P[:-1], P[1:], a, b) - if np.any(intersects): - return True - return False + return np.any(intersects) + + def contains_arc(self, a, b): + """ + Returns `True` if the polygon fully encloses the arc given by a + and b. + """ + return self.contains_point(a) and self.contains_point(b) def area(self): r""" -- cgit