-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewport.cpp
More file actions
17 lines (16 loc) · 757 Bytes
/
Copy pathViewport.cpp
File metadata and controls
17 lines (16 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "Viewport.h"
Viewport::Viewport(const ImageDimensions &dim, const Camera &cam) :
m_height { 2 * calc_h(cam) * cam.focal_length() }
, m_width {m_height * (static_cast<double>(dim.width) / gsl::narrow_cast<int>(dim.height))}
, m_horizontal {cam.u() * m_width}
, m_vertical {cam.v() * -m_height}
, m_upper_left {
cam.center()
- (cam.focal_length() * cam.w())
- (m_horizontal/2)
- (m_vertical/2)
}
, m_horizontalPixelDelta {m_horizontal / gsl::narrow_cast<int>(dim.width)}
, m_verticalPixelDelta {m_vertical / gsl::narrow_cast<int>(dim.height)}
, m_pixel00 {m_upper_left + (0.5 * m_horizontalPixelDelta + m_verticalPixelDelta)}
{ }