Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Fix converting to global coords in threePointArc
Browse files Browse the repository at this point in the history
Add more elaborate testcases with workplane origin moved and comparing
the result of volumes created by threePointArc and sagittaArc.
  • Loading branch information
gntech committed Apr 27, 2018
1 parent 31453e3 commit b281a4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 2 additions & 4 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,10 +1321,8 @@ def threePointArc(self, point1, point2, forConstruction=False):
"""

startPoint = self._findFromPoint(False)
if not isinstance(point1, Vector):
point1 = self.plane.toWorldCoords(point1)
if not isinstance(point2, Vector):
point2 = self.plane.toWorldCoords(point2)
point1 = self.plane.toWorldCoords(point1)
point2 = self.plane.toWorldCoords(point2)

arc = Edge.makeThreePointArc(startPoint, point1, point2)

Expand Down
19 changes: 15 additions & 4 deletions tests/TestCadQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,11 +1619,22 @@ def testClose(self):
self.assertAlmostEqual(a.val().wrapped.Volume * 2.0, b.val().wrapped.Volume)

# Testcase 3 from issue #238
thickness = 3
length = 10
width = 5
thickness = 3.0
length = 10.0
width = 5.0

obj = Workplane('XY', origin=(0, 0, -thickness / 2)) \
obj1 = Workplane('XY', origin=(0, 0, -thickness / 2)) \
.moveTo(length / 2, 0).threePointArc((0, width / 2), (-length / 2, 0)) \
.threePointArc((0, -width / 2), (length / 2, 0)) \
.close().extrude(thickness)

os_x = 8.0 # Offset in X
os_y = -19.5 # Offset in Y

obj2 = Workplane('YZ', origin=(os_x, os_y, -thickness / 2)) \
.moveTo(os_x + length / 2, os_y).sagittaArc((os_x -length / 2, os_y), width / 2) \
.sagittaArc((os_x + length / 2, os_y), width / 2) \
.close().extrude(thickness)

# The obj1 shape shall have the same volume as the obj2 shape.
self.assertAlmostEqual(obj1.val().wrapped.Volume, obj2.val().wrapped.Volume)

0 comments on commit b281a4c

Please sign in to comment.