fn random_in_unit_sphere() -> Vec3 {
    let mut p: Vec3;
    let mut rng = rand::thread_rng();
    let mut noise = || rng.gen::<Real>();
    while {
        p = 2. * Vec3::new(noise(), noise(), noise()) - Vec3::new(1., 1., 1.);
        p.dot(&p) >= 1.
    } { /* Black magic; do-while loop. */ }
    p
}
/// Sample a random point in a unit radius sphere using a rejection method.
Sample a random point in a unit radius sphere using a rejection method.
Sample a random point in a unit radius sphere using a rejection method .
fn random_in_unit_sphere() -> Vec3 {
    let mut p: Vec3;
    let mut rng = rand::thread_rng();
    let mut noise = || rng.gen::<Real>();
    while {
        p = 2. * Vec3::new(noise(), noise(), noise()) - Vec3::new(1., 1., 1.);
        p.dot(&p) >= 1.
    } { /* Black magic; do-while loop. */ }
    p
}
fn random_in_unit_sphere ( ) -> Vec3 { let mut p : Vec3 ; let mut rng = rand :: thread_rng ( ) ; let mut noise = | | rng . gen :: < Real > ( ) ; while { p = 2. * Vec3 :: new ( noise ( ) , noise ( ) , noise ( ) ) - Vec3 :: new ( 1. , 1. , 1. ) ; p . dot ( & p ) >= 1. } { /* Black magic; do-while loop. */ } p }
Sample a random point in a unit radius sphere using a rejection method.
Sample a random point in a unit radius sphere using a rejection method .