Skip to main content

Bridson Poisson DisK Sampling with Variable Radius

This package contains a Python 3 implementation of the Poisson Disk Sampling algorithm of Bridson (2007). It has been adapted to be able to generate the sampling with a spatially variable sampling radius, i.e. the density of the sampling points is determined according to a given density distribution.

Usage

The usage of the package is illustrated in the included example.py file and the generated Poisson Disk Samplings for a set of input density distributions are displayed below and in the subdirectory exampleVisualisations.

The only required input of the routine is a 2D array specifying the sampling radii at each spatial position of the sampling grid. For instance, a uniform density distribution with a sampling radius of 5 and a sampling box of size 40x40 can be generated with

rad = np.zeros((40,40)) + 5

Note that the routine assumes the minimum chosen sampling radius to be 1.

Subsequently, the Poisson Disk Sampling can be generated via

from poissonDiskSampling import bridsonVariableRadius
nParticle, particleCoordinates = bridsonVariableRadius.poissonDiskSampling(rad, k=30, radiusType='default')

with the output nParticle containing the number of generated particles of the sampling and the 2D array particleCoordinates specifying the coordinates of these sampling particles.

The optional argument k states the number of attempts to create a new particle in the annulus between r and 2r around an existing particle. Following Bridson (2007), the default number is set to k=30 but higher values might be necessary some situations.

The other optional argument radiusType can be used to exploit a variation of the original Bridson (2007) algorithm. The default value of the parameter is default in which case it implements the original approach: potential new particles are created in an annulus between radius r and 2r around an already existing particle. If radiusType ='normDist' is set instead, the radii of new particles are drawn from a normal distribution centered around 1.5r with a standard deviation of 0.2r.

Limitations

Input density distributions with sharp steps in density or continuous density gradients along the x or y-axis of the grid sometimes result in an incomplete sampling. Often these issues can be avoided by increasing the number of iterations k used to spawn new particles in an annulus around an existing particle from the default value of k=30 to, for instance, k=100.

Examples

The figures below illustrate the generated Poisson Disk Samplings for a number of exemplary input density distributions.

License

This package is released under the MIT license.

Release files for poissonDiskSampling 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poissonDiskSampling 1.0.0
File Size Uploaded
poissonDiskSampling-1.0.0.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poissonDiskSampling 1.0.0
File Interpreter ABI Platform
poissonDiskSampling-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / poissonDiskSampling-1.0.0.tar.gz

Download URL poissonDiskSampling-1.0.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5dea7931eb96c5dd3378960fa0e7a25280855a08fe49b5b22f944fe413cc5731
BLAKE2b-256 checksum
How to use checksums
e89b919ce80c7cc78445da229fc6419b89b77bc3067c31fd67b29bd892a372cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / poissonDiskSampling-1.0.0-py3-none-any.whl

Download URL poissonDiskSampling-1.0.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
277bd822922b3fb1eaa09d272ef5031d78c7a0ad1ed56d4f4c0bbe9e163ae1a0
BLAKE2b-256 checksum
How to use checksums
fc7753b7572dfc59098e4d9a368dd9f7243b2a0207205bdb110090050f14c57d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page