-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.h
45 lines (34 loc) · 1.11 KB
/
Camera.h
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
38
39
40
41
42
43
44
45
#ifndef RTSIM_CAMERA_H
#define RTSIM_CAMERA_H
#include "Vector.h"
class Camera {
public:
Camera() {
// Outputted image (image space)
this->aspect_ratio = 16.0/9.0;
this->image_width = 1000;
this->image_height = static_cast<int>(this->image_width / this->aspect_ratio);
// "Camera sensor" (scene space)
this->viewport_height = 2.0;
this->viewport_width = this->viewport_height * this->aspect_ratio;
// Distance "eye" is behind viewport
this->focal_length = 1.0;
// Viewport position
this->origin = P3(0.0, 0.0, 0.0);
this->horizontal = V3(this->viewport_width, 0.0, 0.0);
this->vertical = V3(0.0, this->viewport_height, 0.0);
this->lower_left_corner = this->origin - this->horizontal/2 - this->vertical/2 - V3(0, 0, this->focal_length);
}
public:
double aspect_ratio;
double image_width;
double image_height;
double viewport_height;
double viewport_width;
double focal_length;
P3 origin;
V3 horizontal;
V3 vertical;
V3 lower_left_corner;
};
#endif //RTSIM_CAMERA_H