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

37
tests/test_plane.py Normal file
View File

@@ -0,0 +1,37 @@
import numpy as np
from plane import Plane
from ray import Ray
from vector import Vector
def test_plane():
p = Plane(
Vector.fromargs(0, 0, 0),
Vector.fromargs(0, 0, 1),
)
assert (p & Vector.fromargs(0, 0, 0))
assert (p & Vector.fromargs(1, 1, 0))
assert not (p & Vector.fromargs(0, 0, -1))
p = Plane(
Vector.fromargs(1, 1),
Vector.fromargs(1, 1),
)
assert not (p & Vector.fromargs(0, 0))
assert (p & Vector.fromargs(2, 0))
def test_reflection():
p = Plane(
Vector.fromargs(0, 0),
Vector.fromargs(0, 1),
)
r = Ray(
Vector.fromargs(-1, 1),
Vector.fromargs(1, -1),
)
assert p.intersect(r) == np.sqrt(2)