(self)
| 4577 | self.assertAlmostEqual(plate_6.Volume(), 1, 2) |
| 4578 | |
| 4579 | def testTangentArcToPoint(self): |
| 4580 | |
| 4581 | # create a simple shape with tangents of straight edges and see if it has the correct area |
| 4582 | s0 = ( |
| 4583 | Workplane("XY") |
| 4584 | .hLine(1) |
| 4585 | .tangentArcPoint((1, 1), relative=False) |
| 4586 | .hLineTo(0) |
| 4587 | .tangentArcPoint((0, 0), relative=False) |
| 4588 | .close() |
| 4589 | .extrude(1) |
| 4590 | ) |
| 4591 | area0 = s0.faces(">Z").val().Area() |
| 4592 | self.assertAlmostEqual(area0, (1 + math.pi * 0.5 ** 2), 4) |
| 4593 | |
| 4594 | # test relative coords |
| 4595 | s1 = ( |
| 4596 | Workplane("XY") |
| 4597 | .hLine(1) |
| 4598 | .tangentArcPoint((0, 1), relative=True) |
| 4599 | .hLineTo(0) |
| 4600 | .tangentArcPoint((0, -1), relative=True) |
| 4601 | .close() |
| 4602 | .extrude(1) |
| 4603 | ) |
| 4604 | self.assertTupleAlmostEquals( |
| 4605 | s1.val().Center().toTuple(), s0.val().Center().toTuple(), 4 |
| 4606 | ) |
| 4607 | self.assertAlmostEqual(s1.val().Volume(), s0.val().Volume(), 4) |
| 4608 | |
| 4609 | # consecutive tangent arcs |
| 4610 | s1 = ( |
| 4611 | Workplane("XY") |
| 4612 | .vLine(2) |
| 4613 | .tangentArcPoint((1, 0)) |
| 4614 | .tangentArcPoint((1, 0)) |
| 4615 | .tangentArcPoint((1, 0)) |
| 4616 | .vLine(-2) |
| 4617 | .close() |
| 4618 | .extrude(1) |
| 4619 | ) |
| 4620 | self.assertAlmostEqual( |
| 4621 | s1.faces(">Z").val().Area(), 2 * 3 + 0.5 * math.pi * 0.5 ** 2, 4 |
| 4622 | ) |
| 4623 | |
| 4624 | # tangentArc on the end of a spline |
| 4625 | # spline will be a simple arc of a circle, then finished off with a |
| 4626 | # tangentArcPoint |
| 4627 | angles = [idx * 1.5 * math.pi / 10 for idx in range(10)] |
| 4628 | pts = [(math.sin(a), math.cos(a)) for a in angles] |
| 4629 | s2 = ( |
| 4630 | Workplane("XY") |
| 4631 | .spline(pts) |
| 4632 | .tangentArcPoint((0, 1), relative=False) |
| 4633 | .close() |
| 4634 | .extrude(1) |
| 4635 | ) |
| 4636 | # volume should almost be pi, but not accurately because we need to |
nothing calls this directly
no test coverage detected