From 54104319f952a1119241416201cbcea4745bcb22 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 28 Jul 2016 13:57:17 -0700 Subject: [PATCH] Another theoretical optimization --- Lib/cu2qu/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/cu2qu/__init__.py b/Lib/cu2qu/__init__.py index 19d2429c7..1649e828a 100644 --- a/Lib/cu2qu/__init__.py +++ b/Lib/cu2qu/__init__.py @@ -117,7 +117,8 @@ def cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): tolerance of origin, False otherwise. Assumes that p0 and p3 do fit within tolerance of origin, and just checks the inside of the curve.""" - if abs(p1) <= tolerance and abs(p2) <= tolerance: + # First check p2 then p1, as p2 has higher error early on. + if abs(p2) <= tolerance and abs(p1) <= tolerance: return True # Split. @@ -133,7 +134,8 @@ def cubic_farthest_fit(p0, p1, p2, p3, tolerance): """Returns True if the cubic Bezier p entirely lies within a distance tolerance of origin, False otherwise.""" - if abs(p0) > tolerance or abs(p3) > tolerance: + # First check p3 then p0, as p3 has higher error early on. + if abs(p3) > tolerance or abs(p0) > tolerance: return False return cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance)