@woosh/meep-engine 2.131.3 → 2.131.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/package.json +1 -1
  2. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  3. package/src/core/collection/queue/Deque.js +17 -12
  4. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD.d.ts +1 -0
  5. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD.d.ts.map +1 -1
  6. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD.js +1 -0
  7. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.d.ts +39 -0
  8. package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.js +235 -214
  9. package/src/core/math/physics/mie/compute_lorenz_mie_optical_properties.d.ts.map +1 -1
  10. package/src/core/math/physics/mie/compute_lorenz_mie_optical_properties.js +3 -342
  11. package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.js +1 -1
  12. package/src/core/math/physics/mie/compute_mie_phase.d.ts +16 -0
  13. package/src/core/math/physics/mie/compute_mie_phase.d.ts.map +1 -0
  14. package/src/core/math/physics/mie/compute_mie_phase.js +84 -0
  15. package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts +28 -0
  16. package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts.map +1 -0
  17. package/src/core/math/physics/mie/lorenz_mie_coefs.js +232 -0
  18. package/src/core/math/physics/mie/mie_ab_to_optical_properties.d.ts +14 -0
  19. package/src/core/math/physics/mie/mie_ab_to_optical_properties.d.ts.map +1 -0
  20. package/src/core/math/physics/mie/mie_ab_to_optical_properties.js +109 -0
  21. package/src/core/model/node-graph/node/NodeInstance.d.ts +2 -0
  22. package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
  23. package/src/core/model/node-graph/node/NodeInstance.js +11 -5
  24. package/src/engine/animation/curve/AnimationCurve.d.ts +18 -3
  25. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  26. package/src/engine/animation/curve/AnimationCurve.js +69 -36
@@ -1,344 +1,5 @@
1
- import { assert } from "../../../assert.js";
2
- import { v2_dot } from "../../../geom/vec2/v2_dot.js";
3
- import { v2_length } from "../../../geom/vec2/v2_length.js";
4
- import { complex_add } from "../../complex/complex_add.js";
5
- import { complex_div } from "../../complex/complex_div.js";
6
- import { complex_mul } from "../../complex/complex_mul.js";
7
- import { complex_sub } from "../../complex/complex_sub.js";
8
-
9
- // Complex number operations
10
-
11
- function vec2(x, y) {
12
- return new Float64Array([x, y]);
13
- }
14
-
15
- function vec4(x, y, z, w) {
16
- return new Float64Array([x, y, z, w]);
17
- }
18
-
19
- function cadd(a, b) {
20
- const r = vec2(0, 0);
21
-
22
- complex_add(r, a, b);
23
-
24
- return r;
25
- }
26
-
27
- function csub(a, b) {
28
- const r = vec2(0, 0);
29
-
30
-
31
- complex_sub(r, a, b);
32
-
33
- return r;
34
- }
35
-
36
- function cmult(a, b) {
37
- const r = vec2(0, 0);
38
-
39
-
40
- complex_mul(r, a, b);
41
-
42
- return r;
43
- }
44
-
45
- function cdiv(a, b) {
46
- const r = vec2(0, 0);
47
-
48
-
49
- complex_div(r, a, b);
50
-
51
- return r;
52
- }
53
-
54
- // Number of terms to include in infinite sums (truncation)
55
- function terms_to_sum(z) {
56
- const size = v2_length(z[0], z[1]);
57
- return Math.ceil(size + 4.3 * Math.cbrt(size) + 1.0);
58
- }
59
-
60
-
61
- // Downward recurrence for A
62
- function A_all_n(z, M) {
63
- const A = new Array(M + 2);
64
- A[M + 1] = vec2(0.0, 0.0);
65
- for (let n = M; n >= 0; --n) {
66
- const tmp = cdiv(vec2(n + 1.0, 0.0), z);
67
- A[n] = csub(tmp, cdiv(vec2(1.0, 0.0), cadd(tmp, A[n + 1])));
68
- }
69
- return A;
70
- }
71
-
72
- // Upward recurrences for B, psi_zeta, and R
73
- function psi_zeta(n, z, A, old_B, old_psi_zeta) {
74
- if (n > 0) {
75
- const n_z = cdiv(vec2(n, 0.0), z);
76
- const tmp = cmult(csub(n_z, A[n - 1]), csub(n_z, old_B));
77
- old_psi_zeta = cmult(old_psi_zeta, tmp);
78
- }
79
- return old_psi_zeta;
80
- }
81
-
82
- /**
83
- * Calculates the B_n(z) coefficient for term 'n' via upward recurrence.
84
- * This is a helper function for LorenzMie_ab.
85
- *
86
- * @param {number} n - The current recurrence term index (n >= 0).
87
- * @param {vec2} z - The complex size parameter (x or y).
88
- * @param {Array<vec2>} A - Pre-computed log-derivatives A_n(z).
89
- * @param {vec2} old_B - The previous B coefficient (B_{n-1}).
90
- * @param {vec2} old_psi_zeta - The previous psi_zeta product term.
91
- * @returns {vec2} The new B_n coefficient (complex number).
92
- */
93
- function B(n, z, A, old_B, old_psi_zeta) {
94
-
95
- if (n > 0) {
96
- old_B.psi_zeta = psi_zeta(n, z, A, old_B, old_psi_zeta);
97
- old_B = cadd(A[n], cdiv(vec2(0.0, 1.0), old_B.psi_zeta));
98
- }
99
-
100
- return old_B;
101
- }
102
-
103
- /**
104
- * Calculates the R_n(z) coefficient (ratio psi_n / zeta_n) for term 'n'.
105
- * This is a helper function for LorenzMie_ab.
106
- *
107
- * @param {number} n - The current recurrence term index (n >= 0).
108
- * @param {vec2} z - The complex size parameter (x).
109
- * @param {Array<vec2>} A - Pre-computed log-derivatives A_n(z).
110
- * @param {vec2} B_n - The current B_n(z) coefficient.
111
- * @param {vec2} old_R - The previous R coefficient (R_{n-1}).
112
- * @returns {vec2} The new R_n coefficient (complex number).
113
- */
114
- function R(n, z, A, B_n, old_R) {
115
- if (n > 0) {
116
- const n_z = cdiv(vec2(n, 0.0), z);
117
- const tmp = cdiv(cadd(B_n, n_z), cadd(A[n], n_z));
118
- old_R = cmult(old_R, tmp);
119
- }
120
- return old_R;
121
- }
122
-
123
- /**
124
- * Calculates the Lorenz-Mie scattering coefficients a_n and b_n for a single term 'n'.
125
- * This implements the formulas from Figure 3 of Frisvad et al. 2007.
126
- *
127
- * @param {number} n - The current recurrence term index (n >= 0).
128
- * @param {number} size - Unitless size parameter x_vac = 2*pi*r / lambda_vac.
129
- * @param {vec2} n_p - Complex refractive index of the particle.
130
- * @param {vec2} n_med - Complex refractive index of the medium.
131
- * @param {Array<vec2>} A_p - Pre-computed log-derivatives A_n(y) for the particle.
132
- * @param {Array<vec2>} A_med - Pre-computed log-derivatives A_n(x) for the medium.
133
- * @param {vec2} old_B - The previous B_{n-1}(x) coefficient.
134
- * @param {vec2} old_R - The previous R_{n-1}(x) coefficient.
135
- * @param {vec2} old_psi_zeta - The previous psi_zeta product.
136
- * @returns {vec4} A vec4 [Re(a_n), Im(a_n), Re(b_n), Im(b_n)] with state properties
137
- * (.old_B, .old_R, .old_psi_zeta) attached for the next iteration.
138
- */
139
- function LorenzMie_ab(n, size, n_p, n_med, A_p, A_med, old_B, old_R, old_psi_zeta) {
140
-
141
- const x = vec2(size * n_med[0], size * n_med[1]);
142
- const B_n = B(n, x, A_med, old_B, old_psi_zeta);
143
- const R_n = R(n, x, A_med, B_n, old_R);
144
- const n_med_A_p = cmult(n_med, A_p[n]);
145
- const n_p_A_med = cmult(n_p, A_med[n]);
146
- const n_p_A_p = cmult(n_p, A_p[n]);
147
- const n_med_A_med = cmult(n_med, A_med[n]);
148
- const n_p_B_n = cmult(n_p, B_n);
149
- const n_med_B_n = cmult(n_med, B_n);
150
- const a = cmult(R_n, cdiv(csub(n_med_A_p, n_p_A_med), csub(n_med_A_p, n_p_B_n)));
151
- const b = cmult(R_n, cdiv(csub(n_p_A_p, n_med_A_med), csub(n_p_A_p, n_med_B_n)));
152
-
153
-
154
- const ab = vec4(a[0], a[1], b[0], b[1]);
155
-
156
- ab.old_psi_zeta = n > 0 ? old_B.psi_zeta : old_psi_zeta;
157
- ab.old_B = B_n;
158
- ab.old_R = R_n;
159
-
160
- return ab;
161
- }
162
-
163
- /**
164
- * The following source code implements Lorenz-Mie theory using the formulas presented in the SIGGRAPH 2007 paper
165
- *
166
- * Computing the Scattering Properties of Participating
167
- * Media Using Lorenz-Mie Theory
168
- *
169
- * By authors: Jeppe Revall Frisvad
170
- * Niels Joergen Christensen
171
- * Henrik Wann Jensen
172
- *
173
- * Code written by Jeppe Revall Frisvad, 2017.
174
- * Copyright (c) Jeppe Revall Frisvad 2017
175
- *
176
- * Permission is granted to anyone to use this code as
177
- * software for any purpose, including commercial applications.
178
- * However, the software is provided 'as-is' without any warranty.
179
- *
180
- * @param {number} radius_m - Particle radius (in meters).
181
- * @param {number} wavelength_m - Wavelength of light in vacuum (in meters).
182
- * @param {vec2} n_p - Complex refractive index of the particle
183
- * @param {vec2} n_med - Complex refractive index of the medium (e.g., [1.0, 0.0] for air).
184
- */
185
- function lorenz_mie_coefs(
186
- wavelength_m,
187
- radius_m,
188
- n_p,
189
- n_med
190
- ) {
191
-
192
- assert.isNumber(wavelength_m, 'wavelength_m');
193
- assert.isFinite(wavelength_m, 'wavelength_m');
194
- assert.greaterThan(wavelength_m, 0, 'wavelength_m');
195
-
196
- assert.isNumber(radius_m, 'radius_m');
197
- assert.isFinite(radius_m, 'radius_m');
198
- assert.greaterThan(radius_m, 0, 'radius_m');
199
-
200
- const psize = 2.0 * Math.PI * radius_m / wavelength_m;
201
-
202
- const x = vec2(psize * n_med[0], psize * n_med[1]);
203
- const y = vec2(psize * n_p[0], psize * n_p[1]);
204
- const M = terms_to_sum(x);
205
- const A_med = A_all_n(x, M);
206
- const A_p = A_all_n(y, M);
207
-
208
- const e_term = Math.exp(2.0 * x[1]);
209
-
210
- let prev_psi_zeta = vec2(0.5 * (1.0 - Math.cos(2.0 * x[0]) / e_term), -0.5 * Math.sin(2.0 * x[0]) / e_term);
211
- let prev_B = vec2(0.0, 1.0);
212
- let prev_R = vec2(0.5 * (1.0 - Math.cos(2.0 * x[0]) * e_term), 0.5 * Math.sin(2.0 * x[0]) * e_term);
213
-
214
- const ab = new Float64Array(M * 4);
215
-
216
- for (let n = 0; n < M; ++n) {
217
-
218
- const ab_n = LorenzMie_ab(
219
- n, psize, n_p, n_med, A_p, A_med,
220
- prev_B, prev_R, prev_psi_zeta
221
- );
222
-
223
- prev_psi_zeta = ab_n.old_psi_zeta;
224
- prev_B = ab_n.old_B;
225
- prev_R = ab_n.old_R;
226
-
227
- // plug the data in
228
- ab[4 * n] = ab_n[0];
229
- ab[4 * n + 1] = ab_n[1];
230
- ab[4 * n + 2] = ab_n[2];
231
- ab[4 * n + 3] = ab_n[3];
232
- }
233
- return ab;
234
- }
235
-
236
- /**
237
- * Calculates the final optical properties by summing the Mie coefficients.
238
- * This function implements Equations (2) and (3) from the 2007 paper
239
- * "Computing the Scattering Properties of Participating Media..."
240
- *
241
- * @param {Float32Array} ab - The flat array of a_n, b_n coefficients from LorenzMie_coefs.
242
- * @param {number} radius - Particle radius (in meters).
243
- * @param {number} wavelength - Wavelength of light in vacuum (in meters).
244
- * @param {vec2} n_med - Complex refractive index of the medium (e.g., [1.0, 0.0] for air).
245
- * @returns {object} An object with Q_e, Q_s, albedo, C_ext, and C_sca.
246
- */
247
- function ab_to_optical_properties(
248
- ab,
249
- wavelength,
250
- radius,
251
- n_med
252
- ) {
253
- const M = ab.length / 4;
254
-
255
- let sum_t = vec2(0, 0); // Complex sum for Ct
256
- let sum_s = 0; // Real sum for Cs
257
- let sum_g = 0; // Real sum for Asymmetry (g)
258
-
259
- for (let n = 1; n < M; ++n) {
260
- // The 'n' in the paper's formulas
261
- const multiplier = 2 * n + 1;
262
-
263
- // Get an and bn from your flat array
264
- const an = vec2(ab[4 * n], ab[4 * n + 1]);
265
- const bn = vec2(ab[4 * n + 2], ab[4 * n + 3]);
266
-
267
- // 1. For Extinction (Ct)
268
- const an_plus_bn = cadd(an, bn);
269
- // You need complex math functions cadd, cdiv
270
- const n_med_sq = cmult(n_med, n_med);
271
- const term_t = cdiv(an_plus_bn, n_med_sq);
272
- sum_t = cadd(sum_t, cmult(vec2(multiplier, 0), term_t));
273
-
274
- // 2. For Scattering (Cs)
275
- const an_mag_sq = an[0] * an[0] + an[1] * an[1];
276
- const bn_mag_sq = bn[0] * bn[0] + bn[1] * bn[1];
277
- sum_s += multiplier * (an_mag_sq + bn_mag_sq);
278
-
279
- // 3. Asymmetry Accumulation (New)
280
- // Term A: Interference of an and bn
281
- // Formula: (2n+1) / (n(n+1)) * Re(an * bn*)
282
- const factor_A = (2 * n + 1) / (n * (n + 1));
283
- sum_g += factor_A * v2_dot(an[0], an[1], bn[0], bn[1]);
284
-
285
- // Term B: Interference of n and n+1
286
- // Formula: (n(n+2)) / (n+1) * Re(an * an+1* + bn * bn+1*)
287
- if (n < M - 1) {
288
- const n_next = n + 1;
289
- const an1_r = ab[4 * n_next];
290
- const an1_i = ab[4 * n_next + 1];
291
- const bn1_r = ab[4 * n_next + 2];
292
- const bn1_i = ab[4 * n_next + 3];
293
-
294
- const factor_B = (n * (n + 2)) / (n + 1);
295
-
296
- const term_an_an1 = v2_dot(an[0], an[1], an1_r, an1_i);
297
- const term_bn_bn1 = v2_dot(bn[0], bn[1], bn1_r, bn1_i);
298
-
299
- sum_g += factor_B * (term_an_an1 + term_bn_bn1);
300
- }
301
- }
302
-
303
- // --- Final Calculations ---
304
-
305
- // Asymmetry Parameter (g)
306
- // g = (4/x^2 * sum_g) / (2/x^2 * sum_s) => 2 * sum_g / sum_s
307
- let g = 0;
308
- if (sum_s > 1e-12) {
309
- g = (2 * sum_g) / sum_s;
310
- }
311
-
312
- // Extinction (Ct from Eq. 22)
313
- const C_t = (Math.pow(wavelength, 2) / (2 * Math.PI)) * sum_t[0]; //
314
-
315
- // Scattering (Cs from Eq. 23)
316
- const alpha = (4 * Math.PI * radius * n_med[1]) / wavelength;
317
- let gamma;
318
- if (Math.abs(alpha) < 1e-10) {
319
- // avoid division by 0
320
- gamma = 1;
321
- } else {
322
- gamma = (2 * (1 + (alpha - 1) * Math.exp(alpha))) / Math.pow(alpha, 2);
323
- }
324
- const n_med_mag_sq = n_med[0] * n_med[0] + n_med[1] * n_med[1];
325
- const C_s_factor = (Math.pow(wavelength, 2) * Math.exp(-alpha)) / (2 * Math.PI * gamma * n_med_mag_sq);
326
- const C_s = C_s_factor * sum_s;
327
-
328
- // Bulk Coefficients (assuming number density N)
329
- const sigma_a_med = (4 * Math.PI * n_med[1]) / wavelength;
330
-
331
- // To get bulk coefficients sigma_t and sigma_s, use the following formulae, where N is numeric density (particles per cubic meter):
332
- // sigma_t = sigma_a_med + C_t * N;
333
- // sigma_s = C_s * N;
334
-
335
- return {
336
- sigma_a_med,
337
- C_ext: C_t,
338
- C_sca: C_s,
339
- g, // Anisotropy parameter
340
- }
341
- }
1
+ import { lorenz_mie_coefs } from "./lorenz_mie_coefs.js";
2
+ import { mie_ab_to_optical_properties } from "./mie_ab_to_optical_properties.js";
342
3
 
343
4
  /**
344
5
  * For refractive index, the imaginary part controls the absorption coefficient.
@@ -358,6 +19,6 @@ export function compute_lorenz_mie_optical_properties(
358
19
  ) {
359
20
  const ab = lorenz_mie_coefs(wavelength, radius, n_p, n_med);
360
21
 
361
- return ab_to_optical_properties(ab, wavelength, radius, n_med);
22
+ return mie_ab_to_optical_properties(ab, wavelength, radius, n_med);
362
23
  }
363
24
 
@@ -108,7 +108,7 @@ export function compute_mie_particle_properties_rgb(
108
108
 
109
109
  // Resolve G
110
110
  // If the particle is invisible (no scattering), default to isotropic (0)
111
- const final_g = g_weight_total > 1e-12 ? (g_weighted_accumulator / g_weight_total) : 0;
111
+ const final_g = g_weight_total > 1e-20 ? (g_weighted_accumulator / g_weight_total) : 0;
112
112
 
113
113
  // convert XYZ -> sRGB
114
114
 
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Computes the normalized Mie phase function value for a specific angle.
3
+ *
4
+ * The phase function P(theta) is normalized such that the integral over 4pi solid angle is 4pi.
5
+ * This implementation uses the recurrence relations for angular functions pi_n and tau_n as described by Bohren & Huffman.
6
+ *
7
+ * @param {Float32Array} ab - The flat array of a_n, b_n coefficients from LorenzMie_coefs.
8
+ * @param {number} C_sca total scattering cross-section for normalization
9
+ * @param {number} wavelength - Wavelength of light in vacuum (in meters).
10
+ * @param {vec2} n_med - Complex refractive index of the medium.
11
+ * @param {number} cos_theta - Cosine of the angle between incoming light and observation angle.
12
+ * @returns {number} The normalized phase function value P(theta).
13
+ */
14
+ export function compute_mie_phase(ab: Float32Array, C_sca: number, n_med: typeof vec2, wavelength: number, cos_theta: number): number;
15
+ import { vec2 } from "./lorenz_mie_coefs.js";
16
+ //# sourceMappingURL=compute_mie_phase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_mie_phase.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/physics/mie/compute_mie_phase.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,sCAPW,YAAY,SACZ,MAAM,kCACN,MAAM,aAEN,MAAM,GACJ,MAAM,CAsElB;qBAnFoB,uBAAuB"}
@@ -0,0 +1,84 @@
1
+ import { vec2 } from "./lorenz_mie_coefs.js";
2
+
3
+ /**
4
+ * Computes the normalized Mie phase function value for a specific angle.
5
+ *
6
+ * The phase function P(theta) is normalized such that the integral over 4pi solid angle is 4pi.
7
+ * This implementation uses the recurrence relations for angular functions pi_n and tau_n as described by Bohren & Huffman.
8
+ *
9
+ * @param {Float32Array} ab - The flat array of a_n, b_n coefficients from LorenzMie_coefs.
10
+ * @param {number} C_sca total scattering cross-section for normalization
11
+ * @param {number} wavelength - Wavelength of light in vacuum (in meters).
12
+ * @param {vec2} n_med - Complex refractive index of the medium.
13
+ * @param {number} cos_theta - Cosine of the angle between incoming light and observation angle.
14
+ * @returns {number} The normalized phase function value P(theta).
15
+ */
16
+ export function compute_mie_phase(
17
+ ab,
18
+ C_sca,
19
+ n_med,
20
+ wavelength,
21
+ cos_theta,
22
+ ) {
23
+
24
+ // If there is effectively no scattering, return isotropic phase (1.0)
25
+ if (C_sca < 1e-30) return 1.0;
26
+
27
+ const M = ab.length / 4;
28
+
29
+ // Initialize sums as scalars (faster than array access)
30
+ // S1 = Real + Imaginary parts
31
+ let S1_r = 0.0;
32
+ let S1_i = 0.0;
33
+
34
+ // S2 = Real + Imaginary parts
35
+ let S2_r = 0.0;
36
+ let S2_i = 0.0;
37
+
38
+ // Angular function recurrence initialization
39
+ let pi_prev = 0.0; // pi_0 = 0
40
+ let pi_cur = 1.0; // pi_1 = 1
41
+
42
+ for (let n = 1; n < M; ++n) {
43
+ // 1. Load Coefficients directly (Zero Allocation)
44
+ const idx = 4 * n;
45
+ const an_r = ab[idx];
46
+ const an_i = ab[idx + 1];
47
+ const bn_r = ab[idx + 2];
48
+ const bn_i = ab[idx + 3];
49
+
50
+ // 2. Angular Recurrence
51
+ // tau_n = n * cos_theta * pi_n - (n + 1) * pi_{n-1}
52
+ const tau_cur = n * cos_theta * pi_cur - (n + 1) * pi_prev;
53
+
54
+ // 3. Update Sums
55
+ // factor = (2n + 1) / (n(n + 1))
56
+ const factor = (2 * n + 1) / (n * (n + 1));
57
+
58
+ // S1 += factor * (an * pi + bn * tau)
59
+ S1_r += factor * (an_r * pi_cur + bn_r * tau_cur);
60
+ S1_i += factor * (an_i * pi_cur + bn_i * tau_cur);
61
+
62
+ // S2 += factor * (an * tau + bn * pi)
63
+ S2_r += factor * (an_r * tau_cur + bn_r * pi_cur);
64
+ S2_i += factor * (an_i * tau_cur + bn_i * pi_cur);
65
+
66
+ // 4. Prepare next iteration
67
+ // pi_{n+1} = ((2n + 1) * cos * pi_n - (n + 1) * pi_{n-1}) / n
68
+ const pi_next = ((2 * n + 1) * cos_theta * pi_cur - (n + 1) * pi_prev) / n;
69
+ pi_prev = pi_cur;
70
+ pi_cur = pi_next;
71
+ }
72
+
73
+ // Calculate Intensity: (|S1|^2 + |S2|^2) / 2
74
+ const S1_sq = S1_r * S1_r + S1_i * S1_i;
75
+ const S2_sq = S2_r * S2_r + S2_i * S2_i;
76
+ const intensity = 0.5 * (S1_sq + S2_sq);
77
+
78
+ // Wavenumber in medium k = 2pi * Re(n_med) / lambda
79
+ const k_med = (2.0 * Math.PI * n_med[0]) / wavelength;
80
+ const k2 = k_med * k_med;
81
+
82
+ // Normalization: P(theta) = 4pi * I / (k^2 * C_sca)
83
+ return (4.0 * Math.PI * intensity) / (k2 * C_sca);
84
+ }
@@ -0,0 +1,28 @@
1
+ export function vec2(x: any, y: any): Float64Array;
2
+ export function cadd(a: any, b: any): Float64Array;
3
+ export function cmult(a: any, b: any): Float64Array;
4
+ export function cdiv(a: any, b: any): Float64Array;
5
+ /**
6
+ * The following source code implements Lorenz-Mie theory using the formulas presented in the SIGGRAPH 2007 paper
7
+ *
8
+ * "Computing the Scattering Properties of Participating Media Using Lorenz-Mie Theory"
9
+ *
10
+ * By authors: Jeppe Revall Frisvad
11
+ * Niels Joergen Christensen
12
+ * Henrik Wann Jensen
13
+ *
14
+ * Code written by Jeppe Revall Frisvad, 2017.
15
+ * Copyright (c) Jeppe Revall Frisvad 2017
16
+ *
17
+ * Permission is granted to anyone to use this code as
18
+ * software for any purpose, including commercial applications.
19
+ * However, the software is provided 'as-is' without any warranty.
20
+ *
21
+ * @param {number} radius_m - Particle radius (in meters).
22
+ * @param {number} wavelength_m - Wavelength of light in vacuum (in meters).
23
+ * @param {vec2} n_p - Complex refractive index of the particle
24
+ * @param {vec2} n_med - Complex refractive index of the medium (e.g., [1.0, 0.0] for air).
25
+ * @returns {Float64Array} Mie coefficients a_n and b_n in form [a_n0.r, a_n0.i, b_n0.r, b_n0.i, ... a_nN.r, a_nN.i, b_nN.r, b_nN.i]
26
+ */
27
+ export function lorenz_mie_coefs(wavelength_m: number, radius_m: number, n_p: typeof vec2, n_med: typeof vec2): Float64Array;
28
+ //# sourceMappingURL=lorenz_mie_coefs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lorenz_mie_coefs.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/physics/mie/lorenz_mie_coefs.js"],"names":[],"mappings":"AAOA,mDAEC;AAMD,mDAMC;AAWD,oDAOC;AAED,mDAOC;AA8GD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+CALW,MAAM,YADN,MAAM,yCAIJ,YAAY,CAqDxB"}