pub fn random_in_unit_sphere() -> Vec3 {
    // TODO: CHECK whether it is efficient to regenerate a random number generator on every function call.
    let mut rng = rand::thread_rng();
    // Start with a vector that has length larger than 1!
    let mut p = Vec3(10., 10., 10.);
    while p.squared_length() >= 1.0 {
        p = 2.0 * Vec3(rng.gen::<f32>(), rng.gen::<f32>(), rng.gen::<f32>()) - Vec3(1., 1., 1.);
    }
    p
}
/// Generate a random vector in the unit sphere.
Generate a random vector in the unit sphere.
Generate a random vector in the unit sphere .
pub fn random_in_unit_sphere() -> Vec3 {
    // TODO: CHECK whether it is efficient to regenerate a random number generator on every function call.
    let mut rng = rand::thread_rng();
    // Start with a vector that has length larger than 1!
    let mut p = Vec3(10., 10., 10.);
    while p.squared_length() >= 1.0 {
        p = 2.0 * Vec3(rng.gen::<f32>(), rng.gen::<f32>(), rng.gen::<f32>()) - Vec3(1., 1., 1.);
    }
    p
}
pub fn random_in_unit_sphere ( ) -> Vec3 { // TODO: CHECK whether it is efficient to regenerate a random number generator on every function call. let mut rng = rand :: thread_rng ( ) ; // Start with a vector that has length larger than 1! let mut p = Vec3 ( 10. , 10. , 10. ) ; while p . squared_length ( ) >= 1.0 { p = 2.0 * Vec3 ( rng . gen :: < f32 > ( ) , rng . gen :: < f32 > ( ) , rng . gen :: < f32 > ( ) ) - Vec3 ( 1. , 1. , 1. ) ; } p }
Generate a random vector in the unit sphere.
Generate a random vector in the unit sphere .