(self)
| 695 | self.assertTupleAlmostEquals(rot, (0, 15, 0), 6) |
| 696 | |
| 697 | def testEdgeWrapperRadius(self): |
| 698 | |
| 699 | # get a radius from a simple circle |
| 700 | e0 = Edge.makeCircle(2.4) |
| 701 | self.assertAlmostEqual(e0.radius(), 2.4) |
| 702 | |
| 703 | # radius of an arc |
| 704 | e1 = Edge.makeCircle(1.8, pnt=(5, 6, 7), dir=(1, 1, 1), angle1=20, angle2=30) |
| 705 | self.assertAlmostEqual(e1.radius(), 1.8) |
| 706 | |
| 707 | # test value errors |
| 708 | e2 = Edge.makeEllipse(10, 20) |
| 709 | with self.assertRaises(ValueError): |
| 710 | e2.radius() |
| 711 | |
| 712 | # radius from a wire |
| 713 | w0 = Wire.makeCircle(10, Vector(1, 2, 3), (-1, 0, 1)) |
| 714 | self.assertAlmostEqual(w0.radius(), 10) |
| 715 | |
| 716 | # radius from a wire with multiple edges |
| 717 | rad = 2.3 |
| 718 | pnt = (7, 8, 9) |
| 719 | direction = (1, 0.5, 0.1) |
| 720 | w1 = Wire.assembleEdges( |
| 721 | [ |
| 722 | Edge.makeCircle(rad, pnt, direction, 0, 10), |
| 723 | Edge.makeCircle(rad, pnt, direction, 10, 25), |
| 724 | Edge.makeCircle(rad, pnt, direction, 25, 230), |
| 725 | ] |
| 726 | ) |
| 727 | self.assertAlmostEqual(w1.radius(), rad) |
| 728 | |
| 729 | # test value error from wire |
| 730 | w2 = Wire.makePolygon([Vector(-1, 0, 0), Vector(0, 1, 0), Vector(1, -1, 0),]) |
| 731 | with self.assertRaises(ValueError): |
| 732 | w2.radius() |
| 733 | |
| 734 | # (I think) the radius of a wire is the radius of it's first edge. |
| 735 | # Since this is stated in the docstring better make sure. |
| 736 | no_rad = Wire.assembleEdges( |
| 737 | [ |
| 738 | Edge.makeLine(Vector(0, 0, 0), Vector(0, 1, 0)), |
| 739 | Edge.makeCircle(1.0, angle1=90, angle2=270), |
| 740 | ] |
| 741 | ) |
| 742 | with self.assertRaises(ValueError): |
| 743 | no_rad.radius() |
| 744 | yes_rad = Wire.assembleEdges( |
| 745 | [ |
| 746 | Edge.makeCircle(1.0, angle1=90, angle2=270), |
| 747 | Edge.makeLine(Vector(0, -1, 0), Vector(0, 1, 0)), |
| 748 | ] |
| 749 | ) |
| 750 | self.assertAlmostEqual(yes_rad.radius(), 1.0) |
| 751 | many_rad = Wire.assembleEdges( |
| 752 | [ |
| 753 | Edge.makeCircle(1.0, angle1=0, angle2=180), |
| 754 | Edge.makeCircle(3.0, pnt=Vector(2, 0, 0), angle1=180, angle2=359), |
nothing calls this directly
no test coverage detected