Exemplo n.º 1
0
    def test_elements_closer_than_ignore(self):
        cs = LineSegmentStorage(["s0", "s1", "s2"])
        cs["s0"]=[0,0,0.],[0,0,3.]
        cs["s1"]=[1,1,3.],[1,-1,-3.]
        cs["s2"]=[0.,0.,0.],[1,-1,-3.]

        self.assertEqual(cs.elements_closer_than(1.5, ignore=set([("s0","s2"),("s2", "s1")])),[("s0","s1")])
        self.assertEqual(cs.elements_closer_than(0.4),[("s0","s2"),("s1", "s2")])
        self.assertEqual(cs.elements_closer_than(0.4, ignore=set([("s0","s2"),("s2", "s1")])),[])
        self.assertEqual(cs.elements_closer_than(0.4, ignore=[("s2","s0")]),[("s1", "s2")])
Exemplo n.º 2
0
 def test_elements_closer_than_parallel_far(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 1, 2], [0, 1, 3.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1), [])
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s1"] = [0, 0, 0.], [0, 0, 1.]
     cs["s0"] = [0, 1, 2], [0, 1, 3.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1), [])
Exemplo n.º 3
0
    def test_elements_closer_than_ignore(self):
        cs = LineSegmentStorage(["s0", "s1", "s2"])
        cs["s0"] = [0, 0, 0.], [0, 0, 3.]
        cs["s1"] = [1, 1, 3.], [1, -1, -3.]
        cs["s2"] = [0., 0., 0.], [1, -1, -3.]

        self.assertEqual(cs.elements_closer_than(
            1.5, ignore=set([("s0", "s2"), ("s2", "s1")])), [("s0", "s1")])
        self.assertEqual(cs.elements_closer_than(0.4),
                         [("s0", "s2"), ("s1", "s2")])
        self.assertEqual(cs.elements_closer_than(
            0.4, ignore=set([("s0", "s2"), ("s2", "s1")])), [])
        self.assertEqual(cs.elements_closer_than(
            0.4, ignore=[("s2", "s0")]), [("s1", "s2")])
Exemplo n.º 4
0
 def test_elements_closer_than_on_same_line(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 0, 2.], [0, 0, 3.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1.01), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(1.), [])
     self.assertEqual(cs.elements_closer_than(0.5), [])
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [1, 0, 0.]
     cs["s1"] = [2, 0, 0.], [3, 0, 0.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.5), [])
Exemplo n.º 5
0
 def test_elements_closer_real_world_example(self):
     cs = LineSegmentStorage(["m0", "m1"])
     cs["m0"] = [0., 0., 1.], [-2.76245752, -6.86976093,  7.54094508]
     cs["m1"] = [-27.57744115,   6.96488989, -
                 22.47619655], [-16.93424799,  -4.0631445, -16.19822301]
     self.assertEqual(cs.elements_closer_than(25), [("m0", "m1")])
Exemplo n.º 6
0
 def test_elements_closer_than_windschief(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 3.]
     cs["s1"] = [1, 1, 3.], [1, -1, -3.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.4), [])
Exemplo n.º 7
0
 def test_elements_closer_than_in_plane(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 3.], [0, 1, 3.]
     cs["s1"] = [1, 0.5, 3.], [2, 0.5, -3.]
     self.assertEqual(cs.elements_closer_than(1.1), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.9), [])
Exemplo n.º 8
0
 def test_elements_closer_than_intersecting(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [-1, -1, -1.], [1, 1, 1.]
     cs["s1"] = [-1, -1, 1.], [1, 1, -1.]
     self.assertEqual(cs.elements_closer_than(1.5), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.001), [("s0", "s1")])
Exemplo n.º 9
0
 def test_elements_closer_than_overlapping(self):
     cs = LineSegmentStorage(["s0", "s1"])
     cs["s0"] = [0, 0, 0.], [0, 0, 1.]
     cs["s1"] = [0, 0, 0.5], [0, 0, 3.]
     self.assertEqual(cs.elements_closer_than(2), [("s0", "s1")])
     self.assertEqual(cs.elements_closer_than(0.5), [("s0", "s1")])