init
This commit is contained in:
30
tests/test_intersections.py
Normal file
30
tests/test_intersections.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import numpy as np
|
||||
|
||||
from intersections import intersect_plane_ray
|
||||
from plane import Plane
|
||||
from ray import Ray
|
||||
from vector import Vector
|
||||
|
||||
|
||||
def test_intersections():
|
||||
r = Ray(
|
||||
Vector.fromargs(0, 0, 1),
|
||||
Vector.fromargs(-1, -1, -1),
|
||||
)
|
||||
p = Plane(
|
||||
Vector.fromargs(0, 0, 0),
|
||||
Vector.fromargs(0, 0, 1),
|
||||
)
|
||||
|
||||
assert intersect_plane_ray(p, r) == Vector.fromargs(-1, -1, 0)
|
||||
|
||||
np.random.seed(0)
|
||||
for i in range(10):
|
||||
p = Plane(Vector.random(), Vector.random())
|
||||
r = Ray(Vector.random(), Vector.random())
|
||||
|
||||
intersection = intersect_plane_ray(p, r)
|
||||
|
||||
print(p, r, intersection)
|
||||
|
||||
assert p & intersection
|
Reference in New Issue
Block a user