Skip to content

Commit 20097a9

Browse files
authored
Merge pull request #901 from lorenzncode/edge-positionAt
paramAt - handle trimmed curves (#686)
2 parents 9c8240f + 7413044 commit 20097a9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ def paramAt(self: Mixin1DProtocol, d: float) -> float:
13411341
curve = self._geomAdaptor()
13421342

13431343
l = GCPnts_AbscissaPoint.Length_s(curve)
1344-
return GCPnts_AbscissaPoint(curve, l * d, 0).Parameter()
1344+
return GCPnts_AbscissaPoint(curve, l * d, curve.FirstParameter()).Parameter()
13451345

13461346
def tangentAt(
13471347
self: Mixin1DProtocol,

tests/test_cadquery.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,6 +4597,19 @@ def testPositionAt(self):
45974597
self.assertTupleAlmostEquals(p0.toTuple(), p2.toTuple(), 6)
45984598
self.assertTupleAlmostEquals(p1.toTuple(), (0, 1, 0), 6)
45994599

4600+
# test with arc of circle
4601+
e = Edge.makeCircle(1, (0, 0, 0), (0, 0, 1), 90, 180)
4602+
p0 = e.positionAt(0.0)
4603+
p1 = e.positionAt(1.0)
4604+
assert p0.toTuple() == approx((0.0, 1.0, 0.0))
4605+
assert p1.toTuple() == approx((-1.0, 0.0, 0.0))
4606+
4607+
w = Wire.assembleEdges([e])
4608+
p0 = w.positionAt(0.0)
4609+
p1 = w.positionAt(1.0)
4610+
assert p0.toTuple() == approx((0.0, 1.0, 0.0))
4611+
assert p1.toTuple() == approx((-1.0, 0.0, 0.0))
4612+
46004613
def testTangengAt(self):
46014614

46024615
pts = [(0, 0), (-1, 1), (-2, 0), (-1, 0)]

0 commit comments

Comments
 (0)