[][src]Crate poisson2d

Poisson disk sampling

Generates 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.

Examples

Generate a non-tiling Poisson disk sampling in [0, 1)2 with disk radius 0.1 using a slower but more accurate algorithm.

use poisson2d::{Builder, Type, algorithm};
use rand::SeedableRng;
use rand::rngs::SmallRng;

fn main() {
    let poisson =
        Builder::with_radius(0.1, Type::Normal)
            .build(SmallRng::from_entropy(), algorithm::Ebeida);
    let samples = poisson.generate();
    println!("{:?}", samples);
}

Generate a tiling Poisson disk sampling in [0, 1)2 with approximately 100 samples and relative disk radius 0.9 using a faster but less accurate algorithm.


fn main() {
    let poisson =
        Builder::with_samples(100, 0.9, Type::Periodic)
            .build(SmallRng::from_entropy(), algorithm::Bridson);
    for sample in poisson {
        println!("{:?}", sample)
    }
}

Modules

algorithm

Module that contains traits that describe Poisson disk sampling generating algorithms.

Structs

Builder

Builder for the generator.

Generator

Generates a Poisson disk sampling in a [0, 1)2 area.

PoissonIter

Iterator for generating a Poisson disk sampling.

Enums

Type

Enum for determining the type of Poisson disk sampling.