pub fn random_cosine_direction() -> Vector3 {
        use std::f32;

        let mut rng = rand::thread_rng();
        let r1 = rng.gen::<f32>();
        let r2 = rng.gen::<f32>();
        let z = (1.0 - r2).sqrt();
        let phi = 2.0 * f32::consts::PI * r1;
        let x = phi.cos() * 2.0 * r2.sqrt();
        let y = phi.sin() * 2.0 * r2.sqrt();

        Vector3::new(x, y, z)
    }
/// Returns a `Vector3` pointing in a random direction.
Returns a `Vector3` pointing in a random direction.
Returns a ` Vector3 ` pointing in a random direction .
pub fn random_cosine_direction() -> Vector3 {
        use std::f32;
        let mut rng = rand::thread_rng();
        let r1 = rng.gen::<f32>();
        let r2 = rng.gen::<f32>();
        let z = (1.0 - r2).sqrt();
        let phi = 2.0 * f32::consts::PI * r1;
        let x = phi.cos() * 2.0 * r2.sqrt();
        let y = phi.sin() * 2.0 * r2.sqrt();
        Vector3::new(x, y, z)
    }
pub fn random_cosine_direction ( ) -> Vector3 { use std :: f32 ; let mut rng = rand :: thread_rng ( ) ; let r1 = rng . gen :: < f32 > ( ) ; let r2 = rng . gen :: < f32 > ( ) ; let z = ( 1.0 - r2 ) . sqrt ( ) ; let phi = 2.0 * f32 :: consts :: PI * r1 ; let x = phi . cos ( ) * 2.0 * r2 . sqrt ( ) ; let y = phi . sin ( ) * 2.0 * r2 . sqrt ( ) ; Vector3 :: new ( x , y , z ) }
Returns a `Vector3` pointing in a random direction.
Returns a ` Vector3 ` pointing in a random direction .