From 20f043a17b261435a28ec0c691c7b5508c6ce116 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 17 May 2017 00:13:11 +0200 Subject: [PATCH] Use the set precision to determine wether two straight lineto (m,l) segments have the same direction and can be collapsed --- scour/scour.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scour/scour.py b/scour/scour.py index 424217f..d8d8b0f 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -403,10 +403,14 @@ default_properties = { # excluded all properties with 'auto' as default } -def is_same_sign(a, b): return (a <= 0 and b <= 0) or (a >= 0 and b >= 0) +def is_same_sign(a, b): + return (a <= 0 and b <= 0) or (a >= 0 and b >= 0) -def is_same_slope(x1, y1, x2, y2): return y1/x1 - y2/x2 == 0 + +def is_same_slope(x1, y1, x2, y2): + diff = y1/x1 - y2/x2 + return scouringContext.plus(1 + diff) == 1 scinumber = re.compile(r"[-+]?(\d*\.?)?\d+[eE][-+]?\d+")