Arc.intersect(): check bounding boxes first

If the bounding boxes don't overlap, there's obviously no intersection.
pull/38/head
Sebastian Kuzminsky 2017-12-30 19:54:24 -07:00
parent 581cb2d3fe
commit 92b1d111ad
1 changed files with 6 additions and 0 deletions

View File

@ -1528,6 +1528,12 @@ class Arc(object):
to let me know if you're interested in such a feature -- or even better
please submit an implementation if you want to code one."""
# If the bounding boxes don't overlap, there's no intersection.
(self_left, self_right, self_bottom, self_top) = self.bbox()
(other_left, other_right, other_bottom, other_top) = other_seg.bbox()
if (self_left > other_right) or (self_right < other_left) or (self_top < other_bottom) or (self_bottom > other_top):
return []
if is_bezier_segment(other_seg):
u1poly = self.u1transform(other_seg.poly())
u1poly_mag2 = real(u1poly)**2 + imag(u1poly)**2