Struct rand_distr::UnitSphere
source · [−]pub struct UnitSphere;
Expand description
Samples uniformly from the surface of the unit sphere in three dimensions.
Implemented via a method by Marsaglia1.
Example
use rand_distr::{UnitSphere, Distribution};
let v: [f64; 3] = UnitSphere.sample(&mut rand::thread_rng());
println!("{:?} is from the unit sphere surface.", v)
Marsaglia, George (1972). Choosing a Point from the Surface of a Sphere. Ann. Math. Statist. 43, no. 2, 645–646. ↩
Trait Implementations
Generate a random value of T
, using rng
as the source of randomness.
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
Auto Trait Implementations
impl RefUnwindSafe for UnitSphere
impl Send for UnitSphere
impl Sync for UnitSphere
impl Unpin for UnitSphere
impl UnwindSafe for UnitSphere
Blanket Implementations
Mutably borrows from an owned value. Read more