-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.h
29 lines (25 loc) · 806 Bytes
/
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
#pragma once
#include "rtweekend.h"
class camera
{
point3 origin;
point3 lower_left_corner;
vec3 horizontal;
vec3 vertical;
public:
camera()
{
const double aspect_ratio = 16.0/9.0;
double viewport_height = 2.0;
double viewport_width = aspect_ratio * viewport_height;
double focal_length = 1.0;
origin = point3(0, 0, 0);
horizontal = vec3(viewport_width, 0, 0); // Offset horizontal vector
vertical = vec3(0, viewport_height, 0); // Offset vertical vector
lower_left_corner = origin - horizontal/2.0 - vertical/2.0 - vec3(0, 0, focal_length);
}
ray get_ray(double u, double v)
{
return ray(origin, lower_left_corner + u*horizontal + v*vertical - origin);
}
};