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

View 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