()
| 665 | |
| 666 | # %% moved |
| 667 | def test_moved(): |
| 668 | |
| 669 | b = box(1, 1, 1) |
| 670 | s = sphere(0.1) |
| 671 | l1 = Location((-1, 0, 0)) |
| 672 | l2 = Location((1, 0, 0)) |
| 673 | l3 = Location((0, 1, 0), (45, 0, 0)) |
| 674 | l4 = Location((0, -1, 0), (-45, 0, 0)) |
| 675 | |
| 676 | bs1 = b.moved(l1, l2) |
| 677 | bs2 = b.moved((l1, l2)) |
| 678 | |
| 679 | assert bs1.Volume() == approx(2) |
| 680 | assert len(bs1.Solids()) == 2 |
| 681 | |
| 682 | assert bs2.Volume() == approx(2) |
| 683 | assert len(bs2.Solids()) == 2 |
| 684 | |
| 685 | # nested move |
| 686 | bs3 = bs1.moved(l3, l4) |
| 687 | |
| 688 | assert bs3.Volume() == approx(4) |
| 689 | assert len(bs3.Solids()) == 4 |
| 690 | |
| 691 | # move with VectorLike |
| 692 | bs4 = b.moved((0, 0, 1), (0, 0, -1)) |
| 693 | bs5 = bs4.moved((1, 0, 0)).move((-1, 0, 0)) |
| 694 | |
| 695 | assert bs4.Volume() == approx(2) |
| 696 | assert vector_equal(bs5.Center(), bs4.Center()) |
| 697 | |
| 698 | # move with direct params |
| 699 | bs6 = b.moved((0, 0, 1)).moved(0, 0, -1) |
| 700 | bs7 = b.moved((0, 0, 1)).moved(z=-1) |
| 701 | bs8 = b.moved(Location((0, 0, 0), (-45, 0, 0))).moved(rx=45) |
| 702 | bs9 = b.moved().move(Location((0, 0, 0), (-45, 0, 0))).move(rx=45) |
| 703 | |
| 704 | assert vector_equal(bs6.Center(), b.Center()) |
| 705 | assert vector_equal(bs7.Center(), b.Center()) |
| 706 | assert vector_equal(bs8.edges(">Z").Center(), b.edges(">Z").Center()) |
| 707 | assert vector_equal(bs9.edges(">Z").Center(), b.edges(">Z").Center()) |
| 708 | |
| 709 | # moved to shape |
| 710 | s1 = s.moved(b.faces()) |
| 711 | s2 = s.moved(b.edges("|Z")) |
| 712 | s3 = s.moved(b.vertices()) |
| 713 | s4 = s.moved(b) |
| 714 | |
| 715 | assert len(s1.Solids()) == 6 # 6 faces |
| 716 | |
| 717 | assert len(s2.Solids()) == 4 |
| 718 | assert s2.Center().z == approx( |
| 719 | 0.5 |
| 720 | ) # spheres should be placed in the middle of the edges |
| 721 | |
| 722 | assert len(s3.Solids()) == 8 # 8 vertices |
| 723 | |
| 724 | assert len(s4.Solids()) == 1 |
nothing calls this directly
no test coverage detected