This commit is contained in:
2019-04-01 16:02:59 +04:00
commit 36d7f037c3
48 changed files with 1933 additions and 0 deletions

22
tests/test_sphere.py Normal file
View File

@@ -0,0 +1,22 @@
import numpy as np
from ray import Ray
from sphere import Sphere
from vector import Vector
def test_intersect():
sphere = Sphere(
r0=Vector.fromargs(0, 0),
radius=1,
)
assert sphere.intersect(Ray(
r0=Vector.fromargs(-2, 0),
e=Vector.fromargs(1, 0),
)) == 1
assert sphere.intersect(Ray(
r0=Vector.fromargs(-1, -1),
e=Vector.fromargs(1, 1),
)) == np.sqrt(2) - 1