-
Notifications
You must be signed in to change notification settings - Fork 1
/
Camera.cpp
39 lines (29 loc) · 892 Bytes
/
Camera.cpp
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
//
// Created by Jackson Hall on 4/27/2020.
//
#include "Camera.h"
#include <cmath>
/** Static Fields */
const double Camera::DEFAULT_MOVE_DISTANCE = 0.25;
const double Camera::DEFAULT_ROTATION_ANGLE = 2;
const double Camera::DEFAULT_FOV = 160;
/** Constructors */
Camera::Camera(double focalDistance) : focalDistance(focalDistance) {
}
/** Static Methods */
/**
* Return the distance of the focus from a Camera's plane/hyperplane to
* render with a field of view of the given degree angle.
*/
double Camera::getFocalDistanceFromFOV(const double fovDegrees) {
// Focal distance is the cosine of half the field of view
return cos(rad(fovDegrees / 2.0 * M_PI / 180));
}
/** Getters */
double Camera::getFocalDistance() const {
return focalDistance;
}
/** Setters */
void Camera::setFocalDistance(const double newFocalDistance) {
focalDistance = newFocalDistance;
}