I have no idea what I'm doing lol
This commit is contained in:
24
raytracer.py
Normal file
24
raytracer.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import numpy as np
|
||||
|
||||
# Z up
|
||||
|
||||
class Raytracer:
|
||||
def __init__(self, window_size, focal_length):
|
||||
self.window_size = window_size
|
||||
self.focal_length = focal_length
|
||||
|
||||
self.cam_pos = np.zeros(3, dtype=np.float32)
|
||||
self.cam_rot = np.zeros(3, dtype=np.float32)
|
||||
self.cam_dir = np.zeros(3, dtype=np.float32)
|
||||
|
||||
def update_cam_rot(self, cam_rot): # pitch (down - top) | yaw (left - right) | roll
|
||||
self.cam_rot = np.array(cam_rot, dtype=np.float32)
|
||||
|
||||
#### calculate camera direction ####
|
||||
self.pitch_sin = np.sin(self.cam_rot[0])
|
||||
|
||||
self.cam_dir[0] = -np.sin(self.cam_rot[1]) * self.pitch_sin # from yaw and pitch
|
||||
self.cam_dir[1] = np.cos(self.cam_rot[1]) * self.pitch_sin # from yaw and pitch
|
||||
self.cam_dir[2] = -np.cos(self.cam_rot[0]) # from pitch
|
||||
|
||||
print(self.cam_dir)
|
||||
Reference in New Issue
Block a user