-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcamera.cpp
More file actions
42 lines (34 loc) · 1.25 KB
/
Copy pathcamera.cpp
File metadata and controls
42 lines (34 loc) · 1.25 KB
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
#include "camera.h"
Camera::Camera()
{
Ponto3 lookfrom;
Ponto3 lookat;
Vetor3 vup;
const double aspect_ratio = RATIO_16_9;
const double viewport_height = 2.0;
const double viewport_width = aspect_ratio * viewport_height;
const double focal_length = 1.0;
origem = Ponto3(0, 0, 0);
horizontal = Vetor3(viewport_width, 0.0, 0.0);
vertical = Vetor3(0.0, viewport_height, 0.0);
canto_esq_inf = origem - horizontal/2 - vertical/2 - Vetor3(0, 0, focal_length);
}
Camera::Camera(Ponto3 lookfrom, Ponto3 lookat, Vetor3 vup, double aspect_ratio)
{
auto viewport_height = 2.0;
auto viewport_width = aspect_ratio * viewport_height;
auto w = unit_vector(lookfrom - lookat);
auto u = unit_vector(produto_vetorial(vup, w));
auto v = produto_vetorial(w, u);
origem = lookfrom;
horizontal = viewport_width * u;
vertical = viewport_height * v;
canto_esq_inf = origem - horizontal/2 - vertical/2 - w;
}
Camera::Camera(Ponto3 origem, Vetor3 canto_esq_inf, Vetor3 horizontal, Vetor3 vertical):
origem(origem),canto_esq_inf(canto_esq_inf),horizontal(horizontal),vertical(vertical)
{}
Raio Camera::get_raio(double u, double v) const
{
return Raio(origem, canto_esq_inf + u*horizontal + v*vertical - origem);
}