pub struct UnitCircle;
Expand description
Samples uniformly from the circumference of the unit circle in two dimensions.
Implemented via a method by von Neumann1.
For a distribution that also samples from the interior of the unit circle,
see UnitDisc
.
For a similar distribution in three dimensions, see UnitSphere
.
§Plot
The following plot shows the unit circle.
§Example
use rand_distr::{UnitCircle, Distribution};
let v: [f64; 2] = UnitCircle.sample(&mut rand::rng());
println!("{:?} is from the unit circle.", v)
von Neumann, J. (1951) Various Techniques Used in Connection with Random Digits. NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing Office, pp. 36-38. ↩
Trait Implementations§
Source§impl Clone for UnitCircle
impl Clone for UnitCircle
Source§fn clone(&self) -> UnitCircle
fn clone(&self) -> UnitCircle
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UnitCircle
impl Debug for UnitCircle
Source§impl<'de> Deserialize<'de> for UnitCircle
impl<'de> Deserialize<'de> for UnitCircle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<F: Float + SampleUniform> Distribution<[F; 2]> for UnitCircle
impl<F: Float + SampleUniform> Distribution<[F; 2]> for UnitCircle
Source§impl Serialize for UnitCircle
impl Serialize for UnitCircle
impl Copy for UnitCircle
Auto Trait Implementations§
impl Freeze for UnitCircle
impl RefUnwindSafe for UnitCircle
impl Send for UnitCircle
impl Sync for UnitCircle
impl Unpin for UnitCircle
impl UnwindSafe for UnitCircle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more