MCPcopy Index your code
hub / github.com/CadQuery/cadquery / testSplineSpecifyingParameters

Method testSplineSpecifyingParameters

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

Source from the content-addressed store, hash-verified

760 self.assertAlmostEqual((test_point - expected_test_point).Length, 0)
761
762 def testSplineSpecifyingParameters(self):
763 points = [(0, 0), (1, 1), (2, 0), (1, -1)]
764 tangents = [(0, 1), (1, 0), (0, -1), (-1, 0)]
765
766 spline1 = (
767 Workplane("XY")
768 .spline(points, tangents=tangents, parameters=[0, 1, 2, 3])
769 .consolidateWires()
770 )
771 # Multiply all parameter values by 10:
772 spline2 = (
773 Workplane("XY")
774 .spline(points, tangents=tangents, parameters=[0, 10, 20, 30])
775 .consolidateWires()
776 )
777
778 # Test point equivalence for parameter, and parameter multiplied by 10:
779 test_point1 = spline1.edges().val().positionAt(1.5, mode="parameter")
780 test_point2 = spline2.edges().val().positionAt(15, mode="parameter")
781 expected_test_point = Vector(1.625, 0.625, 0.0)
782
783 self.assertAlmostEqual((test_point1 - test_point2).Length, 0)
784 self.assertAlmostEqual((test_point1 - expected_test_point).Length, 0)
785
786 # test periodic with parameters
787 spline3 = Workplane().spline(
788 points, periodic=True, parameters=[x for x in range(len(points) + 1)]
789 )
790 self.assertTrue(spline3.val().IsClosed())
791
792 def testSplineWithScaleTrue(self):
793 points = [(0, 0), (1, 1), (2, 0), (1, -1)]

Callers

nothing calls this directly

Calls 8

WorkplaneClass · 0.85
VectorClass · 0.85
consolidateWiresMethod · 0.80
IsClosedMethod · 0.80
splineMethod · 0.45
positionAtMethod · 0.45
valMethod · 0.45
edgesMethod · 0.45

Tested by

no test coverage detected