rainbow/README.md
2023-11-11 11:30:52 -05:00

29 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 几何光学模拟及彩虹模拟
写了几何光学正向光追。考虑了阳光在水珠中的折射反射,统计角度分布从而模拟彩虹
## 使用的数据
- 水的密度:$$\rho(t) = 999.974950 \frac{1 - (t - 3.983035)^2 (t + 301.797)}{522528.9(t+69.34881)}$$
其中 $t$ 是摄氏温度
- 水的折射率:
$$ n = \sqrt{\frac{2C + 1}{1- C}}, \\ C = \bar{\rho} \left( a_0 + a_1 \bar{\rho} + a_2 \bar{T} + a_{3}{\bar{\lambda }}^{2}{\bar{T}}+{\frac {a_{4}}{{\bar{\lambda }}^{2}}}+{\frac {a_{5}}{{\bar{\lambda }}^{2}-{\bar{\lambda }}_{\mathit {UV}}^{2}}}+{\frac {a_{6}}{{\bar{\lambda }}^{2}-{\bar{\lambda }}_{\mathit {IR}}^{2}}}+a_{7}{\bar{\rho }}^{2} \right)$$
其中:$\bar{T} = T/T^*$, $\bar{\rho} = \rho/\rho^*$, $\bar{\lambda} = \lambda/\lambda^*$ 是约化量,$a_{0} = 0.244257733$, $a_{1} = 0.00974634476$, $a_{2} = 0.00373234996$, $a_{3} = 0.000268678472$, $a_4 = 0.0015892057$, $a_{5} = 0.00245934259$, $a_{6} = 0.90070492$, $a_{7} = 0.0166626219$, $T^{*} = 273.15 \ \mathrm{K}$, $\rho^{*} = 1000\ \mathrm{kg/m^3}$, $\lambda^{*} = 589\ \mathrm{nm}$, $\bar\lambda_{\text{IR}} = 5.432937$, $\bar\lambda_{\text{UV}} = 0.229202$。
- 单色光引起的色觉:见 CIE 1931详细数据在 `colorspace.py` 中的 `_CIEXYZ_1931_table`
- 阳光设为 $5250\ {}\degree\rm C$ 的黑体辐射。这与大气上层吻合较好,但与大气底层相比,忽略了水分子的大量吸收峰和氧分子、二氧化碳分子等的吸收峰。
## 模拟过程
- 给定温度
- 对每隔 $1\ \rm{nm}$ 的单色光:
- 计算折射率,进行正向光追。假设光只与单个水珠相遇。入射光的瞄准距离 $d_i = r \sqrt{u_i}$,其中 $u$ 在 $[0,1)$ 中均匀分布;入射光按照黑体辐射设置
- 统计背向出射的光强 - 角度分布
- 转化为 XYZ - 角度分布
- 求和,得到整个频谱的 XYZ - 角度分布
- 转化为 sRGB - 角度分布,作图
### TODO
- 考虑散射效应:
- 这将导致背景不是黑色,而是天空蓝
- 这将导致水珠反射回的光强被削弱