n-dimensional Poisson disk sampling for Julia
pkg> add PoissonDiskSamplingjulia> using PoissonDiskSampling
julia> r = 0.1 # minimum distance between samples
julia> points = PoissonDiskSampling.generate(r, (0,5), (0,3));
julia> typeof(points)
Vector{Tuple{Float64, Float64}} (alias for Array{Tuple{Float64, Float64}, 1})
julia> using Plots
julia> scatter(points)The default number of candidates per active sample is k=30. Increase k to
try harder before giving up on an active sample:
julia> points = PoissonDiskSampling.generate(r, (0,5), (0,3); k=60);Pass an RNG as the first argument to control the random stream:
julia> using Random
julia> rng = MersenneTwister(1234);
julia> points = PoissonDiskSampling.generate(rng, r, (0,5), (0,3));For reproducible output, use an explicit RNG and leave threaded=false.
Set threaded=true to use multiple threads:
julia> points = PoissonDiskSampling.generate(r, (0,5), (0,3); threaded=true);With threaded=true, reproducibility is not guaranteed. The result may differ from
the single-threaded result and may change with thread count or scheduling, even when
using the same RNG seed.
See ?PoissonDiskSampling.generate for details.