-
Notifications
You must be signed in to change notification settings - Fork 1
/
optics.hpp
65 lines (53 loc) · 1.42 KB
/
optics.hpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/** optics.hpp
*
* Various optical helper calsses and formulae
*
* Author: Austin Hendrix
*/
#ifndef OPTICS_H
#define OPTICS_H
#include <list>
#include "spectrum.hpp"
class Index {
public:
virtual double operator()(double wvl) = 0;
};
class FixedIndex : public Index {
public:
virtual double operator()(double wvl) { return idx; }
FixedIndex(double i) : idx(i) {}
private:
double idx;
};
class LayerMatrix {
public:
double m11;
double m12;
double m21;
double m22;
LayerMatrix(double a, double b, double c, double d) : m11(a), m12(b), m21(c), m22(d) {}
LayerMatrix operator*(const LayerMatrix o) const;
};
class Layer {
public:
double thickness; // in nm
Index * idx;
Layer(double t, Index * i) : thickness(t), idx(i) {}
LayerMatrix operator()(const double theta, const double wvl) const;
};
class Film {
public:
virtual Spectrum *transmit(const Spectrum *in, const double angle) const;
virtual Spectrum *reflect(const Spectrum *in, const double angle) const;
void addLayer(Layer l) {layers.push_back(l); }
void print() const;
private:
std::list<Layer> layers;
// TODO: cache calculation results?
LayerMatrix matrix(const double theta, const double wvl) const;
};
class FakeFilm : public Film {
public:
virtual Spectrum *reflect(const Spectrum *in, const double angle) const;
};
#endif