Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
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)
Esempio n. 7
0
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
Esempio n. 8
0
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]))
Esempio n. 9
0
def test_intersect_sphere_and_triangle_return_false():
    assert intersect(y0, t0) is False
Esempio n. 10
0
def test_intersect_triangle_and_ray_return_true():
    assert (intersect(t0, r0) == _intersect_ray_with_triangle(r0, t0)) is True
Esempio n. 11
0
def test_intersect_sphere_and_ray_return_true():
    assert (intersect(y0, x0) == _intersect_ray_with_sphere(x0, y0)) is True
Esempio n. 12
0
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)
Esempio n. 13
0
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