1 unstable release
0.1.0 | Sep 30, 2020 |
---|
#6 in #poisson
32KB
792 lines
poisson2d
poisson2d is a fork of poisson, a library for generating N-dimensional Poisson disk
samplings. It provides a mint
API for compatibility with most computer
graphics linear algebra libraries, but can only generate 2D samplings. If you're interested in higher-dimensional
samplings, see poisson.
Specifically, poisson2d can generate a sampling of points in [0, 1)2 where:
- Sample points fill the space uniformly.
- Sample points stay a given minimum distance apart.
This is equivalent to uniformly filling a unit square with non-overlapping disks of equal radius, where the radius is half the minimum distance:
Due to their blue noise properties, Poisson disk samplings can be used for object placement in procedural texture/world generation, digital stippling, sampling in rendering, or (re)meshing.
Usage
Works with mint 0.5 and rand 0.7.
use poisson2d::{Builder, Type, algorithm};
use rand::FromEntropy;
use rand::rngs::SmallRng;
fn main() {
let poisson =
Builder::with_radius(0.1, Type::Normal)
.build(SmallRng::from_entropy(), algorithm::Ebeida);
println!("{:?}", poisson.generate());
}
Dependencies
~5.5MB
~136K SLoC