Skip to content

Commit

Permalink
Merge pull request #901 from lorenzncode/edge-positionAt
Browse files Browse the repository at this point in the history
paramAt - handle trimmed curves (#686)
  • Loading branch information
jmwright authored Oct 20, 2021
2 parents 9c8240f + 7413044 commit 20097a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ def paramAt(self: Mixin1DProtocol, d: float) -> float:
curve = self._geomAdaptor()

l = GCPnts_AbscissaPoint.Length_s(curve)
return GCPnts_AbscissaPoint(curve, l * d, 0).Parameter()
return GCPnts_AbscissaPoint(curve, l * d, curve.FirstParameter()).Parameter()

def tangentAt(
self: Mixin1DProtocol,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4597,6 +4597,19 @@ def testPositionAt(self):
self.assertTupleAlmostEquals(p0.toTuple(), p2.toTuple(), 6)
self.assertTupleAlmostEquals(p1.toTuple(), (0, 1, 0), 6)

# test with arc of circle
e = Edge.makeCircle(1, (0, 0, 0), (0, 0, 1), 90, 180)
p0 = e.positionAt(0.0)
p1 = e.positionAt(1.0)
assert p0.toTuple() == approx((0.0, 1.0, 0.0))
assert p1.toTuple() == approx((-1.0, 0.0, 0.0))

w = Wire.assembleEdges([e])
p0 = w.positionAt(0.0)
p1 = w.positionAt(1.0)
assert p0.toTuple() == approx((0.0, 1.0, 0.0))
assert p1.toTuple() == approx((-1.0, 0.0, 0.0))

def testTangengAt(self):

pts = [(0, 0), (-1, 1), (-2, 0), (-1, 0)]
Expand Down

0 comments on commit 20097a9

Please sign in to comment.