generated from taichiCourse01/taichi_course_homework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScene_test.py
43 lines (30 loc) · 954 Bytes
/
Scene_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import taichi as ti
import unittest
import Scene
ti.init()
@ti.data_oriented
class TeseSene(unittest.TestCase):
@ti.kernel
def test_sphere(self):
ray = Scene.Ray(ti.Vector([1.0, 0.5, 0.5]), ti.Vector([-1.0, 0.0, 0.0]))
ball = Scene.Sphere(
ti.Vector([0.5, 0.5, 0.5]),
0.1,
Scene.Material.specular,
ti.Vector([1.0, 0.0, 1.0]),
)
out = ball.hit(ray)
self.assertEqual(out[0], 1)
print(out)
@ti.kernel
def test_plane(self):
ray = Scene.Ray(ti.Vector([1.000000, 0.500000, 0.500000]), ti.Vector([-0.815317, 0.276975, -0.508472]))
wall = Scene.Plane(
ti.Vector([0.0, 0.0, 0.0]),
ti.Vector([1.0, 0.0, 0.0]),
Scene.Material.specular,
ti.Vector([1.0, 0.0, 1.0])
)
out = wall.hit(ray)
self.assertEqual(out[0], 1)
print(out)