1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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_rays(self):
return self.grid, self.focal_point-self.grid
|