Пример #1
0
    def test_2d_sphere_constraints_line_intersections(self):
        # Interior inicial point
        ta, tb, intersect = sphere_intersections([0, 0],
                                                 [1, 0], 0.5,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [-0.5, 0.5])
        assert_equal(intersect, True)

        # No intersection between line and circle
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [0, 1], 1,
                                                 entire_line=True)
        assert_equal(intersect, False)

        # Outside inicial point pointing toward outside the circle
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [1, 0], 1,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [-3, -1])
        assert_equal(intersect, True)

        # Outside inicial point pointing toward inside the circle
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [-1, 0], 1.5,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [0.5, 3.5])
        assert_equal(intersect, True)

        # Inicial point on the boundary
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [1, 0], 2,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [-4, 0])
        assert_equal(intersect, True)
Пример #2
0
    def test_2d_sphere_constraints_line_intersections(self):
        # Interior inicial point
        ta, tb, intersect = sphere_intersections([0, 0],
                                                 [1, 0], 0.5,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [-0.5, 0.5])
        assert_equal(intersect, True)

        # No intersection between line and circle
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [0, 1], 1,
                                                 entire_line=True)
        assert_equal(intersect, False)

        # Outside inicial point pointing toward outside the circle
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [1, 0], 1,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [-3, -1])
        assert_equal(intersect, True)

        # Outside inicial point pointing toward inside the circle
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [-1, 0], 1.5,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [0.5, 3.5])
        assert_equal(intersect, True)

        # Inicial point on the boundary
        ta, tb, intersect = sphere_intersections([2, 0],
                                                 [1, 0], 2,
                                                 entire_line=True)
        assert_array_almost_equal([ta, tb], [-4, 0])
        assert_equal(intersect, True)