diff options
author | mdroe <mdroe@stsci.edu> | 2014-06-12 18:30:00 -0400 |
---|---|---|
committer | mdroe <mdroe@stsci.edu> | 2014-06-12 18:30:00 -0400 |
commit | abb82674a02efc161b130f8ffb2b60063d1e3583 (patch) | |
tree | 6909c8502b1582a90b26c22581298582a4842ffa /stsci | |
parent | 67295d20a80e14927559c91ad48fba3c441f76dc (diff) | |
download | stsci.sphere-abb82674a02efc161b130f8ffb2b60063d1e3583.tar.gz |
Handle empty polygons. Avoid unnecessary normalizations.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@32439 fe389314-cf27-0410-b35b-8c050e845b92
Former-commit-id: b5f9a1f914d5cf8ceba1f70e0e02f55aba16ea97
Diffstat (limited to 'stsci')
-rw-r--r-- | stsci/sphere/graph.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/stsci/sphere/graph.py b/stsci/sphere/graph.py index 95503b3..0fbc9a7 100644 --- a/stsci/sphere/graph.py +++ b/stsci/sphere/graph.py @@ -78,8 +78,6 @@ class Graph: source_polygon : `~sphere.polygon.SphericalPolygon` instance, optional The polygon(s) this node came from. Used for bookkeeping. """ - point = vector.normalize_vector(*point) - self._point = np.asanyarray(point) self._source_polygons = set(source_polygons) self._edges = weakref.WeakSet() @@ -233,7 +231,7 @@ class Graph: points = polygon._points if len(points) < 3: - raise ValueError("Too few points in polygon") + return self._source_polygons.add(polygon) @@ -264,21 +262,23 @@ class Graph: node : `~Graph.Node` instance The new node """ - new_node = self.Node(point, source_polygons) + # Any nodes whose Cartesian coordinates are closer together + # than 2 ** -32 will cause numerical problems in the + # intersection calculations, so we merge any nodes that + # are closer together than that. # Don't add nodes that already exist. Update the existing # node's source_polygons list to include the new polygon. - # Nodes that are closer together than 1e-10 are automatically - # merged, since we can't numerically determine whether those - # nodes are the same, or just along an arc. + point = vector.normalize_vector(*point) # TODO: Vectorize this for node in self._nodes: - if great_circle_arc.length(node._point, new_node._point) < 1e-10: + if np.all(np.abs(node._point - point) < 2 ** -32): node._source_polygons.update(source_polygons) return node + new_node = self.Node(point, source_polygons) self._nodes.add(new_node) return new_node |