def test_ray2d_intersect_with_vertical(self): ray1 = ConstructionRay((10, 1), (10, -7)) ray2 = ConstructionRay((-10, 3), (17, -7)) point = ray1.intersect(ray2) assert point.x == 10 assert point.isclose(Vec3(10.0, -4.4074), 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) 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.0)
def test_Ray2D_get_x_y(self): ray1 = ConstructionRay((10, 1), (20, 10)) y = ray1.yof(15) assert math.isclose(y, 5.5) assert math.isclose(ray1.xof(y), 15.0)