Skip to content

2-dimensional Poisson disk sampling for Rust.

License

Notifications You must be signed in to change notification settings

benfrankel/poisson2d

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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());
}

About

2-dimensional Poisson disk sampling for Rust.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%