def test_intersect_ray_with_sphere_false(): r1 = Ray((0, 0, 0), (1, 1, 1)) s1 = Sphere((10, 10, 10), 5) d, intercepts = intersect(r1, s1) intercepts_analytical = [Point([5.0, 0.0, 0.0]), Point([-5.0, 0.0, 0.0])] d_analytical = 2 assert ((intercepts == intercepts_analytical) and (d_analytical == d)) is False
def test__intersect__ray_not_intersect_with_sphere__return_true(): r1 = Ray((100, 100, 100), (200, 200, 100)) s1 = Sphere((0, 0, 0), 5) d, intersections = intersect(r1, s1) calculated_intersections = [0] d_analytical = 0 assert ((intersections == calculated_intersections) and (d_analytical == d)) is True
def test_intersect_no_intersect_ray_with_sphere_true(): r1 = Ray((100, 100, 100), (200, 200, 100)) s1 = Sphere((0, 0, 0), 5) d, intercepts = intersect(r1, s1) intercepts_analytical = [0] d_analytical = 0 assert ((intercepts == intercepts_analytical) and (d_analytical == d)) is True
def test_intersect_ray_with_triangle_true(): t = Triangle((1, 0, 0), (0, 1, 0), (0, 0, 1)) r1 = Ray((0, 0, 0), (1, 1, 1)) d, intercepts = intersect(r1, t) intercepts_analytical = Point( [0.3333333333333333, 0.3333333333333333, 0.3333333333333333]) d_analytical = 1 assert ((intercepts == intercepts_analytical) and (d_analytical == d)) is True
def test__intersect__ray_with_sphere__return_false(): r1 = Ray((0, 0, 0), (1, 1, 1)) s1 = Sphere((10, 10, 10), 3) d, intersections = intersect(r1, s1) calculated_intersections = [ Point([3.0, 0.0, 0.0]), Point([-3.0, 0.0, 0.0]) ] d_analytical = 2 assert ((intersections == calculated_intersections) and (d_analytical == d)) is False
def test_intersection__ray_with_sphere_doesnot_intersect__return_true(): assert (intersect(Ray((0, 10, 0), (1, 0, 0)), Sphere((0, 0, 0), 6.0)) == None)
def test_intersection__ray_with_sphere_intersects_at_two_points_given_intersected_points__return_true( ): assert np.array_equal( intersect(Ray((-1, 0, 0), (1, 0, 0)), Sphere((0, 0, 0), 1.0)), [Point([-1, 0, 0]), Point([1, 0, 0])]) is True
def test_intersection__ray_with_sphere_intersects_at_one_point_given_tangent_point__return_true( ): assert (intersect(Ray((0, 0, 0), (1, 1, 0)), Sphere( (0, 0, 0), 1.0)) == Point([1 / np.sqrt(2), 1 / np.sqrt(2), 0]))
def test_intersect_sphere_and_triangle_return_false(): assert intersect(y0, t0) is False
def test_intersect_triangle_and_ray_return_true(): assert (intersect(t0, r0) == _intersect_ray_with_triangle(r0, t0)) is True
def test_intersect_sphere_and_ray_return_true(): assert (intersect(y0, x0) == _intersect_ray_with_sphere(x0, y0)) is True
from pygeo.objects import Point, Vector, Ray, Sphere, Triangle from pygeo.intersect import intersect """To check if the installation of the package is done and all packages are running""" r1 = Ray((0, 0, 0), (10, 0, 0)) s1 = Sphere((0, 0, 0), 5) d, intercepts = intersect(r1, s1) print('The ', r1, 'intersects ', s1, 'at', intercepts) t = Triangle((1, 0, 0), (0, 1, 0), (0, 0, 1)) r1 = Ray((0, 0, 0), (1, 1, 1)) d, intercepts = intersect(r1, t) print('The ', r1, 'intersects ', t, 'at', intercepts)
def test_intersect_ray_sphere(): r1 = Ray((0, 0, 0), (5, 0, 0)) r2 = Ray((0, 0, 0), (5, 0, 0)) intercepts = intersect(r1, r2) expected = NotImplemented assert (expected == intercepts) is True