コード例 #1
0
ファイル: planar_test.py プロジェクト: angri/nhlib
    def test_nine_positions(self):
        def v2p(*vectors):  # "vectors to points"
            return [Point(*coords)
                    for coords in zip(*geo_utils.cartesian_to_spherical(
                        numpy.array(vectors, dtype=float)
                    ))]

        corners = v2p([6370, 0, -0.5], [6370, 0, 0.5],
                      [6369, 2, 0.5], [6369, 2, -0.5])
        surface = PlanarSurface(1, 2, 3, *corners)

        # first three positions: point projection is above the top edge
        dists = surface.get_min_distance(Mesh.from_points_list(
            v2p([6371, 0, -1.5], [6371, 0, 1.5], [6371, 0, 0.33])
        ))
        self.assertTrue(numpy.allclose(dists, [2 ** 0.5, 2 ** 0.5, 1.0],
                                       atol=1e-4))

        # next three positions: point projection is below the bottom edge
        dists = surface.get_min_distance(Mesh.from_points_list(
            v2p([6368, 2, -1.5], [6368, 2, 1.5], [6368, 2, -0.45])
        ))
        self.assertTrue(numpy.allclose(dists, [2 ** 0.5, 2 ** 0.5, 1.0],
                                       atol=1e-4))

        # next three positions: point projection is left to rectangle,
        # right to it or lies inside
        dists = surface.get_min_distance(Mesh.from_points_list(
            v2p([6369.5, 1, -1.5], [6369.5, 1, 1.5], [6369.5, 1, -0.1])
        ))
        self.assertTrue(numpy.allclose(dists, [1, 1, 0], atol=1e-4))
コード例 #2
0
ファイル: planar_test.py プロジェクト: pslh/nhlib
    def test_nine_positions(self):
        def v2p(*vectors):  # "vectors to points"
            return [Point(*coords)
                    for coords in zip(*geo_utils.cartesian_to_spherical(
                        numpy.array(vectors, dtype=float)
                    ))]

        corners = v2p([6370, 0, -0.5], [6370, 0, 0.5],
                      [6369, 2, 0.5], [6369, 2, -0.5])
        surface = PlanarSurface(1, 2, 3, *corners)

        # first three positions: point projection is above the top edge
        dists = surface.get_min_distance(Mesh.from_points_list(
            v2p([6371, 0, -1.5], [6371, 0, 1.5], [6371, 0, 0.33])
        ))
        self.assertTrue(numpy.allclose(dists, [2 ** 0.5, 2 ** 0.5, 1.0],
                                       atol=1e-4))

        # next three positions: point projection is below the bottom edge
        dists = surface.get_min_distance(Mesh.from_points_list(
            v2p([6368, 2, -1.5], [6368, 2, 1.5], [6368, 2, -0.45])
        ))
        self.assertTrue(numpy.allclose(dists, [2 ** 0.5, 2 ** 0.5, 1.0],
                                       atol=1e-4))

        # next three positions: point projection is left to rectangle,
        # right to it or lies inside
        dists = surface.get_min_distance(Mesh.from_points_list(
            v2p([6369.5, 1, -1.5], [6369.5, 1, 1.5], [6369.5, 1, -0.1])
        ))
        self.assertTrue(numpy.allclose(dists, [1, 1, 0], atol=1e-4))
コード例 #3
0
ファイル: planar_test.py プロジェクト: angri/nhlib
 def test_4(self):
     surface = PlanarSurface(1, 2, 3, *test_data.TEST_7_RUPTURE_2_CORNERS)
     sites = Mesh.from_points_list([Point(-0.3, 0.4)])
     self.assertAlmostEqual(55.6159556,
                            surface.get_min_distance(sites)[0], delta=0.6)
コード例 #4
0
ファイル: planar_test.py プロジェクト: angri/nhlib
 def test_3(self):
     surface = PlanarSurface(1, 2, 3, *test_data.TEST_7_RUPTURE_2_CORNERS)
     sites = Mesh.from_points_list([Point(0, 0)])
     self.assertAlmostEqual(7.01186304977,
                            surface.get_min_distance(sites)[0], places=2)
コード例 #5
0
ファイル: planar_test.py プロジェクト: angri/nhlib
 def test_2(self):
     surface = PlanarSurface(1, 2, 3, *test_data.TEST_7_RUPTURE_6_CORNERS)
     sites = Mesh.from_points_list([Point(-0.25, 0.25)])
     self.assertAlmostEqual(40.1213468,
                            surface.get_min_distance(sites)[0], places=1)
コード例 #6
0
ファイル: planar_test.py プロジェクト: pslh/nhlib
 def test_4(self):
     surface = PlanarSurface(1, 2, 3, *test_data.TEST_7_RUPTURE_2_CORNERS)
     sites = Mesh.from_points_list([Point(-0.3, 0.4)])
     self.assertAlmostEqual(55.6159556,
                            surface.get_min_distance(sites)[0], delta=0.6)
コード例 #7
0
ファイル: planar_test.py プロジェクト: pslh/nhlib
 def test_3(self):
     surface = PlanarSurface(1, 2, 3, *test_data.TEST_7_RUPTURE_2_CORNERS)
     sites = Mesh.from_points_list([Point(0, 0)])
     self.assertAlmostEqual(7.01186304977,
                            surface.get_min_distance(sites)[0], places=2)
コード例 #8
0
ファイル: planar_test.py プロジェクト: pslh/nhlib
 def test_2(self):
     surface = PlanarSurface(1, 2, 3, *test_data.TEST_7_RUPTURE_6_CORNERS)
     sites = Mesh.from_points_list([Point(-0.25, 0.25)])
     self.assertAlmostEqual(40.1213468,
                            surface.get_min_distance(sites)[0], places=1)