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

Method testCylinderCenteringAndDirection

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

Source from the content-addressed store, hash-verified

2620 )
2621
2622 def testCylinderCenteringAndDirection(self):
2623 radius = 10
2624 height = 40
2625
2626 main_directions = [
2627 (1, 0, 0),
2628 (0, 1, 0),
2629 (0, 0, 1),
2630 (-1, 0, 0),
2631 (0, -1, 0),
2632 (0, 0, -1),
2633 ]
2634
2635 centered_values = [
2636 (True, True, True),
2637 (False, False, False),
2638 (True, False, False),
2639 (False, True, False),
2640 (False, False, True),
2641 (True, True, False),
2642 ]
2643
2644 expected_results = [
2645 (0, 0, 0),
2646 (radius, 0.5 * height, radius),
2647 (0, radius, 0.5 * height),
2648 (-0.5 * height, 0, -radius),
2649 (radius, 0, -radius),
2650 (0, 0, -0.5 * height),
2651 ]
2652
2653 for direction, centered, expected_center in zip(
2654 main_directions, centered_values, expected_results
2655 ):
2656 s = Workplane("XY").cylinder(
2657 height, radius, centered=centered, direct=direction,
2658 )
2659 self.assertTupleAlmostEquals(s.val().Center().toTuple(), expected_center, 3)
2660
2661 def testWedgeDefaults(self):
2662 s = Workplane("XY").wedge(10, 10, 10, 5, 5, 5, 5)

Callers

nothing calls this directly

Calls 6

WorkplaneClass · 0.85
cylinderMethod · 0.80
toTupleMethod · 0.45
CenterMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected