def test__intersect_ray_with_triangle_return_true_1(): triangle = Triangle((1, 0, 0), (-1, 0, 0), (0, 1, 0)) ray = Ray((0.5, 0, 0), (0, 0.5, 0)) val = _intersect_ray_with_triangle(ray, triangle) assert (val == 2) is True
def test__intersect_ray_with_triangle_return_false_2(): triangle = Triangle((1, 0, 0), (-1, 0, 0), (0, 1, 0)) ray = Ray((0, 0, 1), (0, 0, 0)) val = _intersect_ray_with_triangle(ray, triangle) assert (val == 0) is False
def test_intersecting_ray_triangle_return_true(): xt = _intersect_ray_with_triangle(r, t) difft = xt - pt dt = abs(np.linalg.norm(difft._vector)) assert (dt < 10**(-5)) == True is True
def test_intersect_triangle_and_ray_return_true(): assert (intersect(t0, r0) == _intersect_ray_with_triangle(r0, t0)) is True
def test_non_intersecting_ray_triangle_return_false(): assert _intersect_ray_with_triangle(r1, t1) is False
def test_given_ray_triangle_no_intersection_return_false(): assert (_intersect_ray_with_triangle( Ray((0, 0, 0), (1, 1, 0)), Triangle( ((1, 1, 0), (3, 1, 0), (2, 0, 1)))) == Point((0, 0, 1))) is True
def test_given_ray_triangle_return_intersection_point(): assert (_intersect_ray_with_triangle( Ray((5, 2, 5), (0, 0, -1)), Triangle( ((0, 0, 0), (10, 0, 0), (5, 10, 0)))) == Point( (0.4, 0.2, 5))) is True