1 unstable release

0.1.0 Sep 30, 2020

#15 in #meshing

Download history 2/week @ 2023-11-09 1/week @ 2023-11-16 2/week @ 2023-11-23 5/week @ 2023-11-30 1/week @ 2023-12-14 2/week @ 2023-12-21 1/week @ 2023-12-28 1/week @ 2024-01-18 1/week @ 2024-01-25 1/week @ 2024-02-01 2/week @ 2024-02-08 17/week @ 2024-02-15 34/week @ 2024-02-22

54 downloads per month

MIT license

32KB
792 lines

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

Dependencies

~3.5MB
~102K SLoC