Ray tracing in a weekend in python

From the book Raytracing in a weekend code adapted to python emacs configuration emacs (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (setq org-src-preserve-indentation t) helper functions from utilities import point3,color,ray,vec3 import math def dot(vec1, vec2): return (vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z ) import math def unit_vector(v): length = math.sqrt(v.x**2+ v.y**2+ v.z**2) return vec3(v.x/length, v.y/length, v.z/length) def ray_color(r): t = hit_sphere(point3(0,0, -1), 0.5, r) if( t > 0....

November 14, 2021 · Tejaswi D Prakash