Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ def parametricCurve(
tol: float = 1e-6,
minDeg: int = 1,
maxDeg: int = 6,
smoothing: Optional[Tuple[float, float, float]] = (1, 1, 1),
smoothing: Optional[Tuple[float, float, float]] = None,
makeWire: bool = True,
) -> T:
"""
Expand All @@ -1959,7 +1959,7 @@ def parametricCurve(
:param tol: tolerance of the algorithm (default: 1e-6)
:param minDeg: minimum spline degree (default: 1)
:param maxDeg: maximum spline degree (default: 6)
:param smoothing: optional parameters for the variational smoothing algorithm (default: (1,1,1))
:param smoothing: optional parameters for the variational smoothing algorithm (default: None)
:param makeWire: convert the resulting spline edge to a wire
:return: a Workplane object with the current point unchanged

Expand Down
18 changes: 18 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -3996,6 +3996,24 @@ def testParametricCurve(self):
self.assertEqual(len(res_edge.ctx.pendingEdges), 1)
self.assertEqual(len(res_edge.ctx.pendingWires), 0)

def testParametricCurveHelixIntegerTurns(self):
def func(t):
return (
math.cos(t * math.pi * 2),
math.sin(t * math.pi * 2),
t,
)

res = Workplane("XY").parametricCurve(func, stop=4)
edge = res.val().Edges()[0]
points = [edge.positionAt(i / 50) for i in range(51)]
radii = [math.sqrt(p.x**2 + p.y**2) for p in points]

self.assertAlmostEqual(edge.startPoint().x, 1, 6)
self.assertAlmostEqual(edge.endPoint().x, 1, 6)
self.assertAlmostEqual(edge.endPoint().z, 4, 6)
self.assertLess(max(abs(r - 1) for r in radii), 1e-4)

def testMakeShellSolid(self):

c0 = math.sqrt(2) / 4
Expand Down