Antkeeper  0.0.1
refraction.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_PHYSICS_LIGHT_REFRACTION_HPP
21 #define ANTKEEPER_PHYSICS_LIGHT_REFRACTION_HPP
22 
23 namespace physics {
24 namespace light {
25 
27 namespace ior {
28 
39 template <class T>
40 T cauchy(T lambda, T a, T b)
41 {
42  return a + b / (lambda * lambda);
43 }
44 
56 template <class T>
57 T cauchy(T lambda, T a, T b, T c)
58 {
59  const T lambda2 = lambda * lambda;
60  return a + b / lambda2 + c / (lambda2 * lambda2);
61 }
62 
75 template <class T>
76 T sellmeier(T lambda, T b1, T c1, T b2, T c2)
77 {
78  const T lambda2 = lambda * lambda;
79 
80  const T t1 = (b1 * lambda2) / (lambda2 - c1);
81  const T t2 = (b2 * lambda2) / (lambda2 - c2);
82 
83  return std::sqrt(T(1) + t1 + t2);
84 }
85 
100 template <class T>
101 T sellmeier(T lambda, T b1, T c1, T b2, T c2, T b3, T c3)
102 {
103  const T lambda2 = lambda * lambda;
104 
105  const T t1 = (b1 * lambda2) / (lambda2 - c1);
106  const T t2 = (b2 * lambda2) / (lambda2 - c2);
107  const T t3 = (b3 * lambda2) / (lambda2 - c3);
108 
109  return std::sqrt(T(1) + t1 + t2 + t3);
110 }
111 
112 } // namespace ior
113 
114 } // namespace light
115 } // namespace physics
116 
117 #endif // ANTKEEPER_PHYSICS_LIGHT_REFRACTION_HPP
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
T cauchy(T lambda, T a, T b)
Two-term form of Cauchy's transmission equation.
Definition: refraction.hpp:40
T sellmeier(T lambda, T b1, T c1, T b2, T c2)
Two-term form of the Sellmeier equation.
Definition: refraction.hpp:76
Physics.
Definition: constants.hpp:23