Crates.io | poisson2d |
lib.rs | poisson2d |
version | 0.1.0 |
source | src |
created_at | 2020-09-30 05:38:00.537679 |
updated_at | 2020-09-30 05:38:00.537679 |
description | Poisson disk sampling generator. |
homepage | |
repository | https://github.com/benfrankel/poisson2d |
max_upload_size | |
id | 294455 |
size | 49,755 |
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:
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.
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());
}