diff --git a/reflection.py b/reflection.py new file mode 100644 index 0000000000000000000000000000000000000000..bdb61f998c1218aff88110a3a10b5cc2990f44f3 --- /dev/null +++ b/reflection.py @@ -0,0 +1,26 @@ +# Show to python where to find the modules +from scene import * +from light import Spotlight +from camera import Camera +from raytracer import raytracer_render +from matplotlib.image import imsave + +camera = Camera(600,600,1) +materiau_sphere_bleue = Material(Vector((0,0,1)), .5, .3, .3, 100, .5) +materiau_sphere_rouge = Material(Vector((1,0,0)), .5, .3, .3, 100, .3) +materiau_sphere_blanche = Material(Vector((1,1,1)), .5, .3, .3, 100, .7) +materiau_sphere_verte= Material(Vector((0,1,0)), .5, .3, .3, 100, .3) +sphere_bleue = Sphere(Vector([0,0,3]), .8, materiau_sphere_bleue) +sphere_rouge = Sphere(Vector([0.5,0.5,2]), .5, materiau_sphere_rouge) +sphere_blanche = Sphere(Vector([0,0,0]), 50, materiau_sphere_blanche) +sphere_verte = Sphere(Vector([2,-2,3]), .5, materiau_sphere_verte) +lumiere = Spotlight(Vector((1,1,0)), Vector((1,1,1))) +scene = Scene() +scene.add_object(sphere_bleue) +scene.add_object(sphere_rouge) +scene.add_object(sphere_blanche) +scene.add_object(sphere_verte) +scene.add_light(lumiere) +affiche = raytracer_render(camera, scene) +imsave('two_spheres_reflection.png',affiche) +print('Done') diff --git a/scenes/reflection.py b/scenes/reflection.py index cde3e1bdd15015c77dbfa529760682662ad46c6d..694f63659c36addf02c0e93597c6d83f6b6a1512 100644 --- a/scenes/reflection.py +++ b/scenes/reflection.py @@ -10,8 +10,8 @@ from matplotlib.image import imsave import sys camera = Camera(200,200,1) -materiau_sphere_bleue = Material(Vector((0,0,1)), .7, .7, .7, 100, .7) -materiau_sphere_rouge = Material(Vector((1,0,0)), .7, .7, .7, 100, .7) +materiau_sphere_bleue = Material(Vector((0,0,1)), .5, .3, .3, 100, .5) +materiau_sphere_rouge = Material(Vector((1,0,0)), .5, .3, .3, 100, .3) sphere_bleue = Sphere(Vector([0,0,3]), .8, materiau_sphere_bleue) sphere_rouge = Sphere(Vector([0.5,0.5,2]), .5, materiau_sphere_rouge) lumiere = Spotlight(Vector((1,1,0)), Vector((1,1,1))) @@ -21,3 +21,4 @@ scene.add_object(sphere_rouge) scene.add_light(lumiere) affiche = raytracer_render(camera, scene) imsave('two_spheres_reflection.png',affiche) +print('Done') diff --git a/scenes/two_spheres_reflection.png b/scenes/two_spheres_reflection.png index 3345277b857a806c034bb22e1094bef0573fbc05..196361e20de713ac5dc8d7c1f2cb55ff4706606a 100644 Binary files a/scenes/two_spheres_reflection.png and b/scenes/two_spheres_reflection.png differ diff --git a/tests/02_rayon.py b/tests/02_rayon.py index 1ce0c2f0970b1d1b089debc914b25d951318e8fa..d3389e7f53cdc89f67fffea9df4ae5dee2900879 100644 --- a/tests/02_rayon.py +++ b/tests/02_rayon.py @@ -25,7 +25,6 @@ r_one = c.ray_at(c.image_nrows, c.image_ncols); r_one_ref_dir = Vector([-1,-1,c.focal_length]) r_one_ref_dir = r_one_ref_dir / r_one_ref_dir.norm() -assert abs(r_one.direction*(r_one_ref_dir) - - r_one.direction.norm() < 0.01), "c.ray_at(c.nrows,c.ncols) should have the direction [-1,-1,c.focal_length."; +assert abs(r_one.direction*(r_one_ref_dir) - r_one.direction.norm()) < 0.01, "c.ray_at(c.nrows,c.ncols) should have the direction [-1,-1,c.focal_length."; diff --git a/two_spheres_reflection.png b/two_spheres_reflection.png new file mode 100644 index 0000000000000000000000000000000000000000..89fa5b3d0f4ce9c9ebddff669a4909cf3cf51d8d Binary files /dev/null and b/two_spheres_reflection.png differ