init
This commit is contained in:
22
tests/test_sphere.py
Normal file
22
tests/test_sphere.py
Normal 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
|
Reference in New Issue
Block a user