Struct fast_poisson::Poisson[][src]

pub struct Poisson<const N: usize> { /* fields omitted */ }

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]

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]

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]

type Item = [f64; N]

The type of the elements being iterated over.

type IntoIter = PoissonIter<N>

Which kind of iterator are we turning this into?

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,