pub fn randomize(self, rng: &mut dyn RngCore) -> Point {
        let a = self.perpendicular();
        let b = self.cross(a);
        let mut x = 2.0;
        let mut y = 2.0;
        let mut z = 2.0;
        let full_dist = rand::distributions::Uniform::new_inclusive(-1.0, 1.0);
        let part_dist = rand::distributions::Uniform::new_inclusive(0.0, 1.0);
        while x * x + y * y + z * z > 1.0 {
            x = rng.sample(part_dist);
            y = rng.sample(full_dist);
            z = rng.sample(full_dist);
        }
        (x * self + y * a + z * b).normalized()
    }
/// Returns a point randomized in its hemisphere
///
/// Uses simple rejection sampling to obtain a point on the hemisphere
///
/// # Arguments
///
/// * `rng` - The random number generator to use
Returns a point randomized in its hemisphere
Uses simple rejection sampling to obtain a point on the hemisphere
Returns a point randomized in its hemisphere Uses simple rejection sampling to obtain a point on the hemisphere
pub fn randomize(self, rng: &mut dyn RngCore) -> Point {
        let a = self.perpendicular();
        let b = self.cross(a);
        let mut x = 2.0;
        let mut y = 2.0;
        let mut z = 2.0;
        let full_dist = rand::distributions::Uniform::new_inclusive(-1.0, 1.0);
        let part_dist = rand::distributions::Uniform::new_inclusive(0.0, 1.0);
        while x * x + y * y + z * z > 1.0 {
            x = rng.sample(part_dist);
            y = rng.sample(full_dist);
            z = rng.sample(full_dist);
        }
        (x * self + y * a + z * b).normalized()
    }
pub fn randomize ( self , rng : & mut dyn RngCore ) -> Point { let a = self . perpendicular ( ) ; let b = self . cross ( a ) ; let mut x = 2.0 ; let mut y = 2.0 ; let mut z = 2.0 ; let full_dist = rand :: distributions :: Uniform :: new_inclusive ( - 1.0 , 1.0 ) ; let part_dist = rand :: distributions :: Uniform :: new_inclusive ( 0.0 , 1.0 ) ; while x * x + y * y + z * z > 1.0 { x = rng . sample ( part_dist ) ; y = rng . sample ( full_dist ) ; z = rng . sample ( full_dist ) ; } ( x * self + y * a + z * b ) . normalized ( ) }
Returns a point randomized in its hemisphere
Uses simple rejection sampling to obtain a point on the hemisphere
Returns a point randomized in its hemisphere Uses simple rejection sampling to obtain a point on the hemisphere
self
rng
&mut dyn RngCore
self
rng
&mut dyn RngCore