Repository navigation
Expand file tree
/
Copy pathtest_generation.py
More file actions
78 lines (57 loc) · 1.89 KB
/
Copy pathtest_generation.py
File metadata and controls
78 lines (57 loc) · 1.89 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from .context import raytracer
import pytest
from raytracer.ray_tracer import (
Sphere,
Camera,
PngScreen,
Scene,
LightSource,
Plane,
Surface,
)
from raytracer.vector import Vector3
@pytest.mark.skip
def test_centered_single_sphere():
scene = Scene()
light2 = LightSource(Vector3(10, 0, -10))
surface = Surface(color=Vector3(100, 0, 0))
sphere1 = Sphere(Vector3(20, 0, 0), 3, surface)
scene.objects.append(sphere1)
scene.light_sources.append(light2)
camera = Camera(
Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(1, 0, 1), screen_distance=10
)
screen = PngScreen("test_centered_single_sphere.png", 400, 400)
camera.set_screen(screen)
camera.ray_for_pixel(50, 50)
camera.take_picture(scene)
@pytest.mark.skip
def test_sphere_position():
scene = Scene()
light2 = LightSource(Vector3(0, -20, -20))
surface = Surface(color=Vector3(100, 0, 0))
sphere1 = Sphere(Vector3(25, -3, -5), 3, surface)
scene.objects.append(sphere1)
scene.light_sources.append(light2)
camera = Camera(
Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(1, 1, 0), screen_distance=10
)
screen = PngScreen("test_sphere_position.png", 600, 400)
camera.set_screen(screen)
camera.ray_for_pixel(50, 50)
camera.take_picture(scene)
@pytest.mark.skip
def test_two_spheres():
scene = Scene()
light2 = LightSource(Vector3(0, -20, -10))
surface = Surface(color=Vector3(100, 0, 0))
sphere1 = Sphere(Vector3(40, 4, 0), 3, surface)
sphere2 = Sphere(Vector3(30, -4, 0), 3, surface)
scene.objects.append(sphere1)
scene.objects.append(sphere2)
scene.light_sources.append(light2)
camera = Camera(Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(1, 1, 0))
screen = PngScreen("test_two_spheres.png", 400, 400)
camera.set_screen(screen)
camera.ray_for_pixel(50, 50)
camera.take_picture(scene)