poisson2d

Crates.iopoisson2d
lib.rspoisson2d
version0.1.0
sourcesrc
created_at2020-09-30 05:38:00.537679
updated_at2020-09-30 05:38:00.537679
descriptionPoisson disk sampling generator.
homepage
repositoryhttps://github.com/benfrankel/poisson2d
max_upload_size
id294455
size49,755
Ben Frankel (benfrankel)

documentation

README

poisson2d

Documentation Crates.io License: MIT Build Status

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:

Example of a Poisson disk sampling represented as non-overlapping disks

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());
}
Commit count: 160

cargo fmt