• 光线折射公式推导:Snell‘s Law


    光线折射公式推导:Snell’s Law

    Figure 1

    设 入射光 i \mathbf{i} i 和 折射光 t \mathbf{t} t 均为单位向量,由Snell’s law可知 η i sin ⁡ θ i = η t sin ⁡ θ t \eta_i \sin \theta_i = \eta_t \sin \theta_t ηisinθi=ηtsinθt

    其中 η i , η t \eta_i,\eta_t ηi,ηt 为反射系数(typically air = 1.0, glass = 1.3–1.7, diamond = 2.4)。

    因为 sin ⁡ θ i = ∣ i ∥ ∣ ∣ i ∣ ,   sin ⁡ θ t = ∣ t ∥ ∣ ∣ t ∣ \sin\theta_i=\cfrac{|\mathbf{i}_{\parallel}|}{|\mathbf{i}|},\ \sin\theta_t=\cfrac{|\mathbf{t}_{\parallel}|}{|\mathbf{t}|} sinθi=ii, sinθt=tt ,故:
    η i ∣ i ∥ ∣ ∣ i ∣ = η t ∣ t ∥ ∣ ∣ t ∣ η i ∣ i ∥ ∣ = η t ∣ t ∥ ∣

    ηi|i||i|=ηt|t||t|ηi|i|=ηt|t|" role="presentation" style="position: relative;">ηi|i||i|=ηt|t||t|ηi|i|=ηt|t|
    ηiii=ηtttηii=ηtt
    又因 i \mathbf{i} i t \mathbf{t} t 平行且方向相同:
    η i ⋅ i ∥ = η t ⋅ t ∥ t ∥ = η i η t ⋅ i ∥ = η i η t ( i + cos ⁡ θ i ⋅ n )
    ηii=ηttt=ηiηti=ηiηt(i+cosθin)" role="presentation" style="position: relative;">ηii=ηttt=ηiηti=ηiηt(i+cosθin)
    ηiit===ηttηtηiiηtηi(i+cosθin)

    其中 i ∥ = i ⋅ n ∣ i ∣ ∣ n ∣ n = cos ⁡ θ i ⋅ n \mathbf{i}_{\parallel}=\cfrac{\mathbf{i}\cdot \mathbf{n}}{|\mathbf{i}| |\mathbf{n}|}\mathbf{n}=\cos \theta_i \cdot \mathbf{n} i=ininn=cosθin.

    又因 t = t ⊥ + t ∥ \mathbf{t}=\mathbf{t}_{\perp}+\mathbf{t}_{\parallel} t=t+t ∣ t ∣ 2 = ∣ t ⊥ ∣ 2 + ∣ t ∥ ∣ 2 |\mathbf{t}|^2=|\mathbf{t}_{\perp}|^2 + |\mathbf{t}_{\parallel}|^2 t2=t2+t2
    ∣ t ⊥ ∣ 2 = ∣ t ∣ 2 − ∣ t ∥ ∣ 2 ∣ t ⊥ ∣ = 1 − ∣ t ∥ ∣ 2 t ⊥ = − 1 − ∣ t ∥ ∣ 2 ⋅ n

    |t|2=|t|2|t|2|t|=1|t|2t=1|t|2n" role="presentation" style="position: relative;">|t|2=|t|2|t|2|t|=1|t|2t=1|t|2n
    t2tt===t2t21t2 1t2 n
    从而:
    t = t ∥ + t ⊥ \mathbf{t}=\mathbf{t}_{\parallel}+\mathbf{t}_{\perp} t=t+t

    // r_in 为射入物体的光线
    vec3 refract(const vec3& r_in, const vec3& outward_normal, double etai_over_etat) {
        double cos_thetai = dot(-r_in, outward_normal);
        vec3 r_out_parallel =  etai_over_etat * (r_in + cos_thetai * outward_normal);
        vec3 r_out_perp = -sqrt(1.0 - r_out_parallel.length_squared()) * outward_normal;
        return r_out_perp + r_out_parallel;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    也可进一步化简:
    t = t ∥ + t ⊥ = η i η t ⋅ ( i + cos ⁡ θ i ⋅ n ) − 1 − ∣ i ∥ ∣ 2 ⋅ n = η i η t ⋅ ( i + cos ⁡ θ i ⋅ n ) − 1 − sin ⁡ 2 θ t ⋅ n = η i η t ⋅ i + ( η i η t cos ⁡ θ i − 1 − sin ⁡ 2 θ t ) ⋅ n

    t=t+t=ηiηt(i+cosθin)1|i|2n=ηiηt(i+cosθin)1sin2θtn=ηiηti+(ηiηtcosθi1sin2θt)n" role="presentation" style="position: relative;">t=t+t=ηiηt(i+cosθin)1|i|2n=ηiηt(i+cosθin)1sin2θtn=ηiηti+(ηiηtcosθi1sin2θt)n
    t====t+tηtηi(i+cosθin)1i2 nηtηi(i+cosθin)1sin2θt nηtηii+(ηtηicosθi1sin2θt )n
    由Snell’s law公式可得 sin ⁡ θ t = η i η t ⋅ sin ⁡ θ i \sin \theta_t=\cfrac{\eta_i}{\eta_t} \cdot \sin \theta_i sinθt=ηtηisinθi
    t = η i η t ⋅ i + ( η i η t cos ⁡ θ i − 1 − ( η i η t ) 2 sin ⁡ 2 θ i   ) ⋅ n = η i η t ⋅ i + ( η i η t cos ⁡ θ i − 1 − ( η i η t ) 2 ( 1 − cos ⁡ 2 θ i ) ) ⋅ n
    t=ηiηti+(ηiηtcosθi1(ηiηt)2sin2θi )n=ηiηti+(ηiηtcosθi1(ηiηt)2(1cos2θi))n" role="presentation" style="position: relative;">t=ηiηti+(ηiηtcosθi1(ηiηt)2sin2θi )n=ηiηti+(ηiηtcosθi1(ηiηt)2(1cos2θi))n
    t==ηtηii+ηtηicosθi1(ηtηi)2sin2θi  nηtηii+ηtηicosθi1(ηtηi)2(1cos2θi) n

    其中 cos ⁡ θ i = i ⋅ n ∣ i ∣ ∣ n ∣ = i ⋅ n \cos\theta_i=\cfrac{\mathbf{i}\cdot \mathbf{n}}{|\mathbf{i}| |\mathbf{n}|}=\mathbf{i}\cdot \mathbf{n} cosθi=inin=in

    全反射现象 Total internal reflection

    对于Snell’s law 的公式 sin ⁡ θ t = η i η t ⋅ sin ⁡ θ i \sin \theta_t=\cfrac{\eta_i}{\eta_t} \cdot \sin \theta_i sinθt=ηtηisinθi ,当空气中的反射率大于物体内的反射率的时候,有可能会出现 η i η t ⋅ sin ⁡ θ i > 1 \cfrac{\eta_i}{\eta_t} \cdot \sin \theta_i>1 ηtηisinθi>1 的情况。

    但是 sin ⁡ θ t \sin\theta_t sinθt 的值一定是小于1的,故等式不可能成立。这个时候光线应该被反射,而不是折射。

  • 相关阅读:
    指针笔试题
    Clear Code for Minimal API
    2.5 数字传输系统
    容器的通俗讲解
    Unity演示Leetcode开香槟过程
    MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!
    一文带你理解@RefreshScope注解实现动态刷新原理
    @WebFilter两种使用方法和失效解决方案
    gentool gen go自动生成表结构
    端到端自动驾驶系列(一):自动驾驶综述解析
  • 原文地址:https://blog.csdn.net/qq_45874328/article/details/127662346