[−][src]Crate poisson
Poisson-disk distribution generation
Generates distribution of points in [0, 1)d where:
- For each point there is disk of certain radius which doesn't intersect with any other disk of other points
- Samples fill the space uniformly
Due it's blue noise properties poisson-disk distribution can be used for object placement in procedural texture/world generation, as source distribution for digital stipling, as distribution for sampling in rendering or for (re)meshing.
Examples
Generate non-tiling poisson-disk distribution in [0, 1)2 with disk radius 0.1 using slower but more accurate algorithm.
extern crate poisson; extern crate rand; extern crate nalgebra as na; use rand::FromEntropy; use rand::rngs::SmallRng; use poisson::{Builder, Type, algorithm}; fn main() { let poisson = Builder::<_, na::Vector2<f64>>::with_radius(0.1, Type::Normal) .build(SmallRng::from_entropy(), algorithm::Ebeida); let samples = poisson.generate(); println!("{:?}", samples); }
Generate tiling poisson-disk distribution in [0, 1)3 with approximately 100 samples and relative disk radius 0.9 using faster but less accurate algorithm.
fn main() { let poisson = Builder::<_, na::Vector3<f32>>::with_samples(100, 0.9, Type::Perioditic) .build(SmallRng::from_entropy(), algorithm::Bridson); for sample in poisson { println!("{:?}", sample) } }
Modules
algorithm | Module that contains traits that describe poisson-disk distribution generating algorithms. |
Structs
Builder | Builder for the generator. |
Generator | Generates poisson-disk distribution in [0, 1]d area. |
PoissonIter | Iterator for generating poisson-disk distribution. |
Enums
Type | Enum for determining the type of poisson-disk distribution. |
Traits
Float | Describes what floats are. |
Vector | Describes what vectors are. |