Update test_641_construction_ray.py
vertical and horizontal intersects should be exact numbers
@@ -46,10 +46,30 @@ class TestConstructionRay:
ray1 = ConstructionRay((10, 1), (10, -7))
ray2 = ConstructionRay((-10, 3), (17, -7))
point = ray1.intersect(ray2)
+ assert point.x == 10
assert point.isclose(Vector(10., -4.4074), abs_tol=1e-4)
with pytest.raises(ArithmeticError):
_ = ray1.yof(1)
+ def test_ray2d_intersect_with_horizontal(self):
+ ray1 = ConstructionRay((-10, 10), (10, 10))
+ ray2 = ConstructionRay((-10, 20), (10, 0))
+ point = ray1.intersect(ray2)
+ assert point.y == 10
+ assert point.isclose(Vector(0.0, 10.0), abs_tol=1e-4)
+ with pytest.raises(ArithmeticError):
+ _ = ray1.yof(1)
+
+ def test_ray2d_intersect_with_vertical_and_horizontal(self):
+ ray1 = ConstructionRay((-10, 10), (10, 10))
+ ray2 = ConstructionRay((5, 0), (5, 20))
+ point = ray1.intersect(ray2)
+ assert point.y == 10
+ assert point.x == 5
+ assert point.isclose(Vector(5.0, 10.0), abs_tol=1e-4)
+ with pytest.raises(ArithmeticError):
+ _ = ray1.yof(1)
+
def test_ray2d_parallel_vertical(self):
ray1 = ConstructionRay((10, 1), (10, -7))
ray2 = ConstructionRay((11, 0), angle=HALF_PI)
