pub fn refract(wi: &Vector3f, n: &Normal3f, eta: Float, wt: &mut Vector3f) -> bool {
    // compute $\cos \theta_\roman{t}$ using Snell's law
    let cos_theta_i: Float = nrm_dot_vec3f(n, wi);
    let sin2_theta_i: Float = (0.0 as Float).max(1.0 as Float - cos_theta_i * cos_theta_i);
    let sin2_theta_t: Float = eta * eta * sin2_theta_i;
    // handle total internal reflection for transmission
    if sin2_theta_t >= 1.0 as Float {
        return false;
    }
    let cos_theta_t: Float = (1.0 as Float - sin2_theta_t).sqrt();
    *wt = -(*wi) * eta + Vector3f::from(*n) * (eta * cos_theta_i - cos_theta_t);
    true
}
/// Computes the refraction direction given an incident direction, a
/// surface normal, and the ratio of indices of refraction (incident
/// and transmitted).
Computes the refraction direction given an incident direction, a
surface normal, and the ratio of indices of refraction (incident
and transmitted).
Computes the refraction direction given an incident direction a surface normal and the ratio of indices of refraction ( incident and transmitted ) .
pub fn refract(wi: &Vector3f, n: &Normal3f, eta: Float, wt: &mut Vector3f) -> bool {
    // compute $\cos \theta_\roman{t}$ using Snell's law
    let cos_theta_i: Float = nrm_dot_vec3f(n, wi);
    let sin2_theta_i: Float = (0.0 as Float).max(1.0 as Float - cos_theta_i * cos_theta_i);
    let sin2_theta_t: Float = eta * eta * sin2_theta_i;
    // handle total internal reflection for transmission
    if sin2_theta_t >= 1.0 as Float {
        return false;
    }
    let cos_theta_t: Float = (1.0 as Float - sin2_theta_t).sqrt();
    *wt = -(*wi) * eta + Vector3f::from(*n) * (eta * cos_theta_i - cos_theta_t);
    true
}
pub fn refract ( wi : & Vector3f , n : & Normal3f , eta : Float , wt : & mut Vector3f ) -> bool { // compute $\cos \theta_\roman{t}$ using Snell's law let cos_theta_i : Float = nrm_dot_vec3f ( n , wi ) ; let sin2_theta_i : Float = ( 0.0 as Float ) . max ( 1.0 as Float - cos_theta_i * cos_theta_i ) ; let sin2_theta_t : Float = eta * eta * sin2_theta_i ; // handle total internal reflection for transmission if sin2_theta_t >= 1.0 as Float { return false ; } let cos_theta_t : Float = ( 1.0 as Float - sin2_theta_t ) . sqrt ( ) ; * wt = - ( * wi ) * eta + Vector3f :: from ( * n ) * ( eta * cos_theta_i - cos_theta_t ) ; true }
Computes the refraction direction given an incident direction, a
surface normal, and the ratio of indices of refraction (incident
and transmitted).
Computes the refraction direction given an incident direction a surface normal and the ratio of indices of refraction ( incident and transmitted ) .
wi
&Vector3f
n
&Normal3f
eta
Float
wt
&mut Vector3f