From 51327a822d96488c6c967b2012840c7f2dbd9fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20Yavuz=20=C3=96ZDERYA?= Date: Thu, 17 Sep 2015 23:07:54 +0300 Subject: [PATCH] normals should be the same, 1 of the faces may have its center on another face but may be none co-planar --- cadquery/CQ.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cadquery/CQ.py b/cadquery/CQ.py index 636c2bb..c9fe07c 100644 --- a/cadquery/CQ.py +++ b/cadquery/CQ.py @@ -299,10 +299,20 @@ class CQ(object): afterwards. """ def _isCoPlanar(f0, f1): + """Test if two faces are on the same plane.""" p0 = f0.Center() p1 = f1.Center() - n = f0.normalAt() - return abs(n.dot(p0.sub(p1)) < self.ctx.tolerance) + n0 = f0.normalAt() + n1 = f1.normalAt() + + # test normals (direction of planes) + if not ((abs(n0.x-n1.x) < self.ctx.tolerance) or + (abs(n0.y-n1.y) < self.ctx.tolerance) or + (abs(n0.z-n1.z) < self.ctx.tolerance)): + return False + + # test if p1 is on the plane of f0 (offset of planes) + return abs(n0.dot(p0.sub(p1)) < self.ctx.tolerance) def _computeXdir(normal): """