-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.py
More file actions
37 lines (32 loc) · 916 Bytes
/
Camera.py
File metadata and controls
37 lines (32 loc) · 916 Bytes
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
from Ray import *
class Camera(object):
"""
"""
def __init__(self, e, c, up):
"""
:param e:
:param c:
:param up:
"""
self.e = e
self.c = c
self.up = up
self.ce = c.__sub__(e)
self.f = self.ce.__div__(self.ce.magnitude())
self.fup = self.f.cross(up)
self.s = self.fup.__div__(self.fup.magnitude())
self.u = self.s.cross(self.f)
def calcRay(self, x, y, pixelWidth, width, pixelHeight, height):
"""
:param x:
:param y:
:param pixelWidth:
:param width:
:param pixelHeight:
:param height:
:return:
"""
xcomp = self.s.scale(x * pixelWidth - width / 2)
ycomp = self.u.scale(y * pixelHeight - height / 2)
ray = Ray(self.e, (self.f + xcomp + ycomp))
return ray