diff options
Diffstat (limited to 'camera.py')
-rw-r--r-- | camera.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/camera.py b/camera.py new file mode 100644 index 0000000..dc3e32e --- /dev/null +++ b/camera.py @@ -0,0 +1,22 @@ +import numpy as np + +class Camera(object): + def __init__(self, size = (800, 600), film_size = (0.035, 0.024), focal_length=0.05): + width, height = size + + grid = [] + for i, x in enumerate(np.linspace(-film_size[0]/2, film_size[0]/2, width)): + for j, z in enumerate(np.linspace(-film_size[1]/2, film_size[1]/2, height)): + grid.append((x,0,z)) + + self.grid = np.array(grid) + self.grid += (0,focal_length,0) + + self.focal_point = np.zeros(3) + + def position(self, position): + self.grid += position + self.focal_point += position + + def get_pixels(self): + return self.grid, self.focal_point-self.grid |