Struct fast_poisson::Poisson [−][src]
Poisson disk distribution in N dimensions
Distributions can be generated for any non-negative number of dimensions, although performance depends upon the volume of the space: for higher-order dimensions you may need to increase the radius to achieve the desired level of performance.
Implementations
impl<const N: usize> Poisson<N>
[src]
pub fn new() -> Self
[src]
Create a new Poisson disk distribution
Currently the same as Default::default()
pub fn with_dimensions(
&mut self,
dimensions: [f64; N],
radius: f64
) -> &mut Self
[src]
&mut self,
dimensions: [f64; N],
radius: f64
) -> &mut Self
Specify the space to be filled and the radius around each point
By default, the output will sample each dimension from the semi-open range [0.0, 1.0). This method can be used to modify the results to fill any arbitrary space.
To generate a 2-dimensional distribution in a 5×5 square, with no points closer than 1:
let mut points = Poisson::<2>::new().with_dimensions([5.0, 5.0], 1.0).iter(); assert!(points.all(|p| p[0] >= 0.0 && p[0] < 5.0 && p[1] >= 0.0 && p[1] < 5.0));
To generate a 3-dimensional distribution in a 3×3×5 prism, with no points closer than 0.75:
let mut points = Poisson::<3>::new().with_dimensions([3.0, 3.0, 5.0], 0.75).iter(); assert!(points.all(|p| { p[0] >= 0.0 && p[0] < 3.0 && p[1] >= 0.0 && p[1] < 3.0 && p[2] >= 0.0 && p[2] < 5.0 }));
pub fn with_seed(&mut self, seed: u64) -> &Self
[src]
Specify the RNG seed for this distribution
If no seed is specified then the internal RNG will be seeded from rand::thread_rng()
,
providing non-deterministic results.
let points = Poisson::<2>::new().with_seed(0xBADBEEF).iter();
pub fn with_samples(&mut self, samples: u32) -> &Self
[src]
Specify the number of samples to generate around each point in the distribution
A higher number may result in better space filling, but will slow down generation. Note that specifying a number of samples does not ensure that the final distribution includes this number of points around each other point; rather, each sample is tested for validity before being included, so the final distribution will have up to the specified number of points generated from each point.
By default 30 samples are selected around each point.
let points = Poisson::<3>::new().with_samples(40).iter();
pub fn iter(&self) -> PoissonIter<N>ⓘNotable traits for PoissonIter<N>
impl<const N: usize> Iterator for PoissonIter<N> type Item = [f64; N];
[src]
Notable traits for PoissonIter<N>
impl<const N: usize> Iterator for PoissonIter<N> type Item = [f64; N];
Returns an iterator over the points in this distribution
let points = Poisson::<3>::new(); for point in points.iter() { println!("{:?}", point); }
Trait Implementations
impl<const N: usize> Clone for Poisson<N>
[src]
impl<const N: usize> Debug for Poisson<N>
[src]
impl<const N: usize> Default for Poisson<N>
[src]
impl<const N: usize> IntoIterator for Poisson<N>
[src]
Auto Trait Implementations
impl<const N: usize> RefUnwindSafe for Poisson<N>
impl<const N: usize> Send for Poisson<N>
impl<const N: usize> Sync for Poisson<N>
impl<const N: usize> Unpin for Poisson<N>
impl<const N: usize> UnwindSafe for Poisson<N>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,