Struct rand::distributions::UnitSphereSurface
source · [−]pub struct UnitSphereSurface;
Expand description
Samples uniformly from the surface of the unit sphere in three dimensions.
Implemented via a method by Marsaglia1.
Example
use rand::distributions::{UnitSphereSurface, Distribution};
let sphere = UnitSphereSurface::new();
let v = sphere.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. ↩
Implementations
sourceimpl UnitSphereSurface
impl UnitSphereSurface
sourcepub fn new() -> UnitSphereSurface
pub fn new() -> UnitSphereSurface
Construct a new UnitSphereSurface
distribution.
Trait Implementations
sourceimpl Clone for UnitSphereSurface
impl Clone for UnitSphereSurface
sourcefn clone(&self) -> UnitSphereSurface
fn clone(&self) -> UnitSphereSurface
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for UnitSphereSurface
impl Debug for UnitSphereSurface
sourceimpl Distribution<[f64; 3]> for UnitSphereSurface
impl Distribution<[f64; 3]> for UnitSphereSurface
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 3]
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 3]
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
D: Distribution<T>,
R: Rng + 'a, type Item = T;
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
impl Copy for UnitSphereSurface
Auto Trait Implementations
impl RefUnwindSafe for UnitSphereSurface
impl Send for UnitSphereSurface
impl Sync for UnitSphereSurface
impl Unpin for UnitSphereSurface
impl UnwindSafe for UnitSphereSurface
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more