Exemplo n.º 1
0
 def test_ray2d_parallel(self):
     ray1 = ConstructionRay((17, -8), (-10, 2))
     ray2 = ConstructionRay((-10, 3), (17, -7))
     ray3 = ConstructionRay((-10, 4), (17, -6))
     assert ray2.is_parallel(ray3) is True
     assert ray1.is_parallel(ray3) is True
     with pytest.raises(ParallelRaysError):
         _ = ray2.intersect(ray3)
Exemplo n.º 2
0
    def test_ray2d_intersect(self):
        ray1 = ConstructionRay((10, 1), (20, 10))
        ray2 = ConstructionRay((17, -7), (-10, 3))

        point = ray1.intersect(ray2)
        assert point.isclose(Vector(5.7434, -2.8309), abs_tol=1e-4)
        assert ray1.is_parallel(ray2) is False
Exemplo n.º 3
0
    def test_two_close_horizontal_rays(self):
        p1 = (39340.75302672016, 32489.73349764998)
        p2 = (39037.75302672119, 32489.73349764978)
        p3 = (38490.75302672015, 32489.73349764997)

        ray1 = ConstructionRay(p1, p2)
        ray2 = ConstructionRay(p2, p3)
        assert ray1.is_horizontal is True
        assert ray2.is_horizontal is True
        assert ray1.is_parallel(ray2) is True
        assert math.isclose(
            ray1.slope,
            ray2.slope) is False, 'Only slope testing is not sufficient'
Exemplo n.º 4
0
 def test_ray2d_parallel_vertical(self):
     ray1 = ConstructionRay((10, 1), (10, -7))
     ray2 = ConstructionRay((11, 0), angle=HALF_PI)
     ray3 = ConstructionRay((12, -10), (12, 7))
     ray4 = ConstructionRay((0, 0), (1, 1))
     ray5 = ConstructionRay((0, 0), angle=0)
     with pytest.raises(ParallelRaysError):
         _ = ray1.intersect(ray3)
     assert ray1.is_parallel(ray3) is True
     assert ray1.is_parallel(ray2) is True
     assert ray2.is_parallel(ray2) is True
     assert ray1.is_parallel(ray4) is False
     assert ray2.is_parallel(ray4) is False
     assert ray3.is_parallel(ray4) is False
     assert ray1.is_parallel(ray5) is False
     assert ray2.is_parallel(ray5) is False
     assert ray3.is_parallel(ray5) is False
     # vertical rays can't calc a y-value
     with pytest.raises(ArithmeticError):
         _ = ray1.yof(-1.)