Beispiel #1
0
    def build_from_w(self, n: Vector3):
        self._w = Vector3.normalize(n)
        if math.fabs(self._w.x()) > 0.9:
            a = Vector3(0, 1, 0)
        else:
            a = Vector3(1, 0, 0)

        self._v = Vector3.normalize(Vector3.cross(self._w, a))
        self._u = Vector3.cross(self._w, self._v)
    def __init__(self, lookfrom:'Vector3', lookat:'Vector3', vectorup:'Vector3', vfov:'float', aspect:'float', aperture:'float', focus_dist:'float', t0:float, t1:float):
        theta =  vfov * math.pi / 180  # vfov to radians
        half_height = math.tan(theta / 2) # h = tan(theta / 2)
        half_width = half_height * aspect

        self._lens_radius = aperture / 2

        self._time0 = t0
        self._time1 = t1

        self._camera_origin = lookfrom
        w = Vector3.normalize(lookfrom - lookat)
        u = Vector3.normalize(Vector3.cross(vectorup, w))
        v = Vector3.cross(w, u)

        self._lower_left_corner = self._camera_origin - half_width * focus_dist * u - half_height * focus_dist * v - focus_dist*w
        self._horizontal = 2 * half_width * focus_dist * u
        self._vertical = 2 * half_height * focus_dist * v