Ejemplo n.º 1
0
 def test_ref_frame(self):
     ref_point = Point(x=1, y=2, z=3)
     frame = create_reference_frame(ref_point)
     self.assertEqual(frame, Frame(x=-1, y=-2, z=-3))
     self.assertEqual(apply_reference_frame(ref_point, frame),
                      self.zero_point)
     self.assertEqual(apply_reference_frame(ref_point, frame),
                      self.zero_point)
Ejemplo n.º 2
0
 def test_tiny_example(self):
     readouts = load_readouts(get_test_file_path("samples/d19/tiny.txt"))
     lhs_frame, rhs_frame, orientation = find_aligned_frames(
         readouts[0], readouts[1], 3)
     lhs_beacons = [
         apply_reference_frame(beacon, lhs_frame)
         for beacon in readouts[0].beacons
     ]
     rhs_beacons = [
         apply_reference_frame(beacon, rhs_frame)
         for beacon in readouts[1].beacons
     ]
     lhs_beacons.sort()
     rhs_beacons.sort()
     self.assertListEqual(lhs_beacons, rhs_beacons)
Ejemplo n.º 3
0
 def test_overlapping_sample_pair(self):
     readouts = load_readouts(
         get_test_file_path("samples/d19/overlapping.txt"))
     rhs_frame, rhs_orientation = find_reference_frame(
         readouts[0], readouts[1], 12)
     rhs_aligned = realign_scanner(readouts[1], rhs_orientation)
     rhs_beacons = [
         apply_reference_frame(beacon, rhs_frame)
         for beacon in rhs_aligned.beacons
     ]
     lhs_beacons = {beacon for beacon in readouts[0].beacons}
     common_beacons = {
         beacon
         for beacon in rhs_beacons if beacon in lhs_beacons
     }
     expected_beacons = {
         Point(x=-618, y=-824, z=-621),
         Point(x=-537, y=-823, z=-458),
         Point(x=-447, y=-329, z=318),
         Point(x=404, y=-588, z=-901),
         Point(x=544, y=-627, z=-890),
         Point(x=528, y=-643, z=409),
         Point(x=-661, y=-816, z=-575),
         Point(x=390, y=-675, z=-793),
         Point(x=423, y=-701, z=434),
         Point(x=-345, y=-311, z=381),
         Point(x=459, y=-707, z=401),
         Point(x=-485, y=-357, z=347)
     }
     self.assertSetEqual(common_beacons, expected_beacons)
Ejemplo n.º 4
0
    def test_overlapping_pair_chain(self):
        expected_beacons = {
            Point(x=459, y=-707, z=401),
            Point(x=-739, y=-1745, z=668),
            Point(x=-485, y=-357, z=347),
            Point(x=432, y=-2009, z=850),
            Point(x=528, y=-643, z=409),
            Point(x=423, y=-701, z=434),
            Point(x=-345, y=-311, z=381),
            Point(x=408, y=-1815, z=803),
            Point(x=534, y=-1912, z=768),
            Point(x=-687, y=-1600, z=576),
            Point(x=-447, y=-329, z=318),
            Point(x=-635, y=-1737, z=486),
        }
        readouts = load_readouts(
            get_test_file_path("samples/d19/overlapping.txt"))
        reference_scanner = readouts[0]
        mid_scanner = readouts[1]
        end_scanner = readouts[4]
        self.assertEqual(reference_scanner.name, "--- scanner 0 ---")
        self.assertEqual(mid_scanner.name, "--- scanner 1 ---")
        self.assertEqual(end_scanner.name, "--- scanner 4 ---")
        mid_frame, mid_orientation = find_reference_frame(
            reference_scanner, mid_scanner, 12)
        mid_aligned = realign_scanner(mid_scanner, mid_orientation)
        mid_beacons = {
            apply_reference_frame(beacon, mid_frame)
            for beacon in mid_aligned.beacons
        }

        end_frame, end_orientation = find_reference_frame(
            mid_aligned, end_scanner, 12)
        end_aligned = realign_scanner(end_scanner, end_orientation)
        end_beacons = [
            apply_reference_frame(beacon, end_frame)
            for beacon in end_aligned.beacons
        ]
        end_beacons = [
            apply_reference_frame(beacon, mid_frame) for beacon in end_beacons
        ]

        common_beacons = {
            beacon
            for beacon in end_beacons if beacon in mid_beacons
        }
        self.assertSetEqual(common_beacons, expected_beacons)
Ejemplo n.º 5
0
 def find_and_apply_common_frame(self, lhs: ScannerReadout,
                                 rhs: ScannerReadout, threshold: int):
     rhs_frame, rhs_orientation = find_reference_frame(lhs, rhs, threshold)
     aligned_beacons = reorient_to_default(rhs.beacons, rhs_orientation)
     rhs_beacons = [
         apply_reference_frame(beacon, rhs_frame)
         for beacon in aligned_beacons
     ]
     rhs_beacons.sort()
     lhs.beacons.sort()
     self.assertListEqual(lhs.beacons, rhs_beacons)