Ejemplo n.º 1
0
 def test_point_outside(self):
     corners = [Point(0.1, -0.1, 1), Point(-0.1, -0.1, 1), Point(-0.1, 0.1, 2), Point(0.1, 0.1, 2)]
     surface = PlanarSurface(1, 270, 45, *corners)
     sites = Mesh.from_points_list(
         [
             Point(-0.2, -0.2),
             Point(1, 1, 1),
             Point(4, 5),
             Point(0.8, 0.01),
             Point(0.2, -0.15),
             Point(0.02, -0.12),
             Point(-0.14, 0),
             Point(-3, 3),
             Point(0.05, 0.15, 10),
         ]
     )
     dists = surface.get_joyner_boore_distance(sites)
     expected_dists = [
         Point(-0.2, -0.2).distance(Point(-0.1, -0.1)),
         Point(1, 1).distance(Point(0.1, 0.1)),
         Point(4, 5).distance(Point(0.1, 0.1)),
         Point(0.8, 0.01).distance(Point(0.1, 0.01)),
         Point(0.2, -0.15).distance(Point(0.1, -0.1)),
         Point(0.02, -0.12).distance(Point(0.02, -0.1)),
         Point(-0.14, 0).distance(Point(-0.1, 0)),
         Point(-3, 3).distance(Point(-0.1, 0.1)),
         Point(0.05, 0.15).distance(Point(0.05, 0.1)),
     ]
     self.assertTrue(numpy.allclose(dists, expected_dists, atol=0.05))
Ejemplo n.º 2
0
 def test_point_on_the_border(self):
     corners = [Point(0.1, -0.1, 1), Point(-0.1, -0.1, 1), Point(-0.1, 0.1, 2), Point(0.1, 0.1, 2)]
     surface = PlanarSurface(1, 270, 45, *corners)
     sites = Mesh.from_points_list([Point(-0.1, 0.04), Point(0.1, 0.03)])
     dists = surface.get_joyner_boore_distance(sites)
     expected_dists = [0] * 2
     self.assertTrue(numpy.allclose(dists, expected_dists))
Ejemplo n.º 3
0
 def test_point_inside(self):
     corners = [Point(-1, -1, 1), Point(1, -1, 1), Point(1, 1, 2), Point(-1, 1, 2)]
     surface = PlanarSurface(10, 90, 45, *corners)
     sites = Mesh.from_points_list([Point(0, 0), Point(0, 0, 20), Point(0.1, 0.3)])
     dists = surface.get_joyner_boore_distance(sites)
     expected_dists = [0] * 3
     self.assertTrue(numpy.allclose(dists, expected_dists))
Ejemplo n.º 4
0
 def test_point_on_the_border(self):
     corners = [Point(0.1, -0.1, 1), Point(-0.1, -0.1, 1),
                Point(-0.1, 0.1, 2), Point(0.1, 0.1, 2)]
     surface = PlanarSurface(270, 45, *corners)
     sites = Mesh.from_points_list([Point(-0.1, 0.04), Point(0.1, 0.03)])
     dists = surface.get_joyner_boore_distance(sites)
     expected_dists = [0] * 2
     aac(dists, expected_dists)
Ejemplo n.º 5
0
 def test_distance_to_2d_mesh(self):
     corners = [Point(0.0, 1.0), Point(1.0, 1.0),
                Point(1.0, 0.114341), Point(0.0, 0.114341)]
     surface = PlanarSurface(90.0, 10.0, *corners)
     sites = Mesh(numpy.array([[0.25, 0.75], [0.25, 0.75]]),
                  numpy.array([[0.75, 0.75], [0.25, 0.25]]),
                  None)
     dists = surface.get_joyner_boore_distance(sites)
     numpy.testing.assert_equal(dists, numpy.zeros((2, 2)))
Ejemplo n.º 6
0
 def test_distance_to_2d_mesh(self):
     corners = [Point(0.0, 1.0), Point(1.0, 1.0),
                Point(1.0, 0.114341), Point(0.0, 0.114341)]
     surface = PlanarSurface(1, 90.0, 10.0, *corners)
     sites = Mesh(numpy.array([[0.25, 0.75], [0.25, 0.75]]),
                  numpy.array([[0.75, 0.75], [0.25, 0.25]]),
                  None)
     dists = surface.get_joyner_boore_distance(sites)
     numpy.testing.assert_equal(dists, numpy.zeros((2, 2)))
Ejemplo n.º 7
0
 def test_point_inside(self):
     corners = [Point(-1, -1, 1), Point(1, -1, 1),
                Point(1, 1, 2), Point(-1, 1, 2)]
     surface = PlanarSurface(10, 90, 45, *corners)
     sites = Mesh.from_points_list([Point(0, 0), Point(0, 0, 20),
                                    Point(0.1, 0.3)])
     dists = surface.get_joyner_boore_distance(sites)
     expected_dists = [0] * 3
     self.assertTrue(numpy.allclose(dists, expected_dists))
Ejemplo n.º 8
0
 def test_point_outside(self):
     corners = [Point(0.1, -0.1, 1), Point(-0.1, -0.1, 1),
                Point(-0.1, 0.1, 2), Point(0.1, 0.1, 2)]
     surface = PlanarSurface(1, 270, 45, *corners)
     sites = Mesh.from_points_list([
         Point(-0.2, -0.2), Point(1, 1, 1), Point(4, 5),
         Point(0.8, 0.01), Point(0.2, -0.15), Point(0.02, -0.12),
         Point(-0.14, 0), Point(-3, 3), Point(0.05, 0.15, 10)
     ])
     dists = surface.get_joyner_boore_distance(sites)
     expected_dists = [
         Point(-0.2, -0.2).distance(Point(-0.1, -0.1)),
         Point(1, 1).distance(Point(0.1, 0.1)),
         Point(4, 5).distance(Point(0.1, 0.1)),
         Point(0.8, 0.01).distance(Point(0.1, 0.01)),
         Point(0.2, -0.15).distance(Point(0.1, -0.1)),
         Point(0.02, -0.12).distance(Point(0.02, -0.1)),
         Point(-0.14, 0).distance(Point(-0.1, 0)),
         Point(-3, 3).distance(Point(-0.1, 0.1)),
         Point(0.05, 0.15).distance(Point(0.05, 0.1))
     ]
     self.assertTrue(numpy.allclose(dists, expected_dists, atol=0.05))