MCPcopy
hub / github.com/CadQuery/cadquery / testPositionAt

Method testPositionAt

tests/test_cadquery.py:4931–4975  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4929 n = edge.normal()
4930
4931 def testPositionAt(self):
4932
4933 # test with an open wire
4934 w = Workplane().lineTo(0, 1).lineTo(1, 1).wire().val()
4935
4936 p0 = w.positionAt(0.0)
4937 p1 = w.positionAt(0.5)
4938 p2 = w.positionAt(1.0)
4939
4940 self.assertTupleAlmostEquals(p0.toTuple(), (0, 0, 0), 6)
4941 self.assertTupleAlmostEquals(p1.toTuple(), (0, 1, 0), 6)
4942 self.assertTupleAlmostEquals(p2.toTuple(), (1, 1, 0), 6)
4943
4944 p0 = w.positionAt(0.0, mode="param")
4945
4946 self.assertTupleAlmostEquals(p0.toTuple(), (0, 0, 0), 6)
4947
4948 p0, p1, p2 = w.positions([0.0, 0.25, 0.5])
4949
4950 self.assertTupleAlmostEquals(p0.toTuple(), (0, 0, 0), 6)
4951 self.assertTupleAlmostEquals(p1.toTuple(), (0, 0.5, 0), 6)
4952 self.assertTupleAlmostEquals(p2.toTuple(), (0, 1, 0), 6)
4953
4954 # test with a closed wire
4955 w = Workplane().lineTo(0, 1).close().wire().val()
4956
4957 p0 = w.positionAt(0.0)
4958 p1 = w.positionAt(0.5)
4959 p2 = w.positionAt(1.0)
4960
4961 self.assertTupleAlmostEquals(p0.toTuple(), p2.toTuple(), 6)
4962 self.assertTupleAlmostEquals(p1.toTuple(), (0, 1, 0), 6)
4963
4964 # test with arc of circle
4965 e = Edge.makeCircle(1, (0, 0, 0), (0, 0, 1), 90, 180)
4966 p0 = e.positionAt(0.0)
4967 p1 = e.positionAt(1.0)
4968 assert p0.toTuple() == approx((0.0, 1.0, 0.0))
4969 assert p1.toTuple() == approx((-1.0, 0.0, 0.0))
4970
4971 w = Wire.assembleEdges([e])
4972 p0 = w.positionAt(0.0)
4973 p1 = w.positionAt(1.0)
4974 assert p0.toTuple() == approx((0.0, 1.0, 0.0))
4975 assert p1.toTuple() == approx((-1.0, 0.0, 0.0))
4976
4977 def testTangengAt(self):
4978

Callers

nothing calls this directly

Calls 11

WorkplaneClass · 0.85
lineToMethod · 0.80
assembleEdgesMethod · 0.80
valMethod · 0.45
wireMethod · 0.45
positionAtMethod · 0.45
toTupleMethod · 0.45
positionsMethod · 0.45
closeMethod · 0.45
makeCircleMethod · 0.45

Tested by

no test coverage detected