forked from UVMCS120BS2020/AB-LF-Project3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectilinear_Lens.cpp
40 lines (33 loc) · 1.25 KB
/
Rectilinear_Lens.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
39
40
//
// Created by Luke on 1/20/2020.
//
#include <cmath>
#include <experimental/optional>
#include "Rectilinear_Lens.h"
using std::experimental::optional;
using std::experimental::nullopt;
using std::experimental::make_optional;
using namespace std;
typedef optional<string> opt_string;
/********************** Rectilinear_Lens class **********************/
Rectilinear_Lens::Rectilinear_Lens() : Lens() {
type = rectilinear;
}
Rectilinear_Lens::Rectilinear_Lens(double focal_length_, double f_stop_, opt_string &name_) : Lens(focal_length_, f_stop_, name_) {
type = rectilinear;
}
double Rectilinear_Lens::field_of_view_horizontal(double magnification, double frame_width) const {
// Horizontal FOV = 2 * ARCTAN( w / (2*f*(m+1)) ) -> convert to degrees
// w = frame width, f = focal length, m = magnification
double m = magnification;
double w = frame_width;
double f = focal_length;
double h_fov = 2 * atan(w / (2*f*(m+1))) * (180.0 / M_PI);
return h_fov;
}
ostream& operator << (ostream& outs, const Rectilinear_Lens &lens) {
outs << "Lens Type =\t" << lens.get_type() << endl;
outs << "Focal Length =\t" << lens.get_focal_length() << " mm" << endl;
outs << "F/stop =\tf/" << lens.get_f_stop() << endl;
return outs;
}