Skip to main content

Poisson Disk Sampling Algorithm with Variable Sampling Radius

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poissonDiskSampling-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

poissonDiskSampling-1.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file poissonDiskSampling-1.0.0.tar.gz.

File metadata

  • Download URL: poissonDiskSampling-1.0.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for poissonDiskSampling-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5dea7931eb96c5dd3378960fa0e7a25280855a08fe49b5b22f944fe413cc5731
MD5 8784624d82a998fafd808bcb44a917b4
BLAKE2b-256 e89b919ce80c7cc78445da229fc6419b89b77bc3067c31fd67b29bd892a372cb

See more details on using hashes here.

File details

Details for the file poissonDiskSampling-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: poissonDiskSampling-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for poissonDiskSampling-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 277bd822922b3fb1eaa09d272ef5031d78c7a0ad1ed56d4f4c0bbe9e163ae1a0
MD5 24621c7b5cfcbf37d7c554513121085b
BLAKE2b-256 fc7753b7572dfc59098e4d9a368dd9f7243b2a0207205bdb110090050f14c57d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page