-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolarisingfilter.h
More file actions
63 lines (50 loc) · 1.88 KB
/
polarisingfilter.h
File metadata and controls
63 lines (50 loc) · 1.88 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef POLARISINGFILTER_H
#define POLARISINGFILTER_H
#include "collideableobject.h"
#include <random>
typedef Eigen::Matrix<std::complex<double>, 2, 2> Matrix22d;
/*!
* \brief The PolarisingFilter class
* This defines the methods the polarising filter will implement.
*/
class PolarisingFilter : public CollideableObject {
Q_OBJECT
Matrix22d m_polarizationMatrix;
Eigen::Vector2d m_targetPolarisation;
Eigen::Vector2cd Er;
double m_radius;
std::complex<double> m_n1;
std::normal_distribution<> dist;
std::mt19937 noise_gen;
int noiseState = 0;
public:
PolarisingFilter(Eigen::Vector3d location, int side, Eigen::Vector3d normal,
double radius, std::complex<double> n1,
Eigen::Vector2d targetPolarisation);
~PolarisingFilter() {}
void collide(Ray &ray, Eigen::Vector3d &pointOfInterception);
bool intersect(Ray &ray, Eigen::Vector3d &pointOfInterception);
ObjectType getType();
Matrix22d getPolarisationMatrix();
void setTarget(Eigen::Vector2d target);
protected:
void calculatePolarisationMatrix();
void calculateAngleOfRefraction(std::complex<double> theta0,
std::complex<double> &theta1) {
std::complex<double> numerator1 = m_n0 * sin(theta0);
theta1 = asin(numerator1 / m_n1); // the angle of refraction
}
void calculateAngleOfInterception(Ray &ray, std::complex<double> &theta0) {
auto normal = this->getNormal();
normal.normalize();
Eigen::Vector3d rayDirection = ray.getDirection();
rayDirection.normalize();
std::complex<double> numerator0 = rayDirection.dot(normal);
std::complex<double> denominator0 = rayDirection.norm() * normal.norm();
theta0 = acos(numerator0 / denominator0); // the angle of incidence
}
signals:
void outputPolarisationUpdated(Matrix4cd polarisation);
void outputEr(Eigen::Vector2cd Er);
};
#endif // POLARISINGFILTER_H