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)
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
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.isclose(Vector(10., -4.4074), abs_tol=1e-4) with pytest.raises(ArithmeticError): _ = ray1.yof(1)
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)
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.)
def test_ray2d_normal(self): ray = ConstructionRay((-10, 3), (17, -7)) ortho = ray.orthogonal((3, 3)) point = ray.intersect(ortho) assert point.isclose(Vector(1.4318, -1.234), abs_tol=1e-4)
def test_ray2d_normal_vertical(self): ray = ConstructionRay((10, 1), (10, -7)) # vertical line ortho = ray.orthogonal((3, 3)) point = ray.intersect(ortho) assert point.isclose(Vector(10, 3))
def test_ray2d_normal_horizontal(self): ray = ConstructionRay((10, 10), (20, 10)) # horizontal line ortho = ray.orthogonal((3, 3)) point = ray.intersect(ortho) assert point.isclose(Vector(3, 10))
def _get_point_on_dimline(point: 'Vertex', dimray: ConstructionRay) -> Vector: """ get the measure target point projection on the dimension line """ return dimray.intersect(dimray.orthogonal(point))