poissonDiskSampling

fun poissonDiskSampling(bounds: Rectangle, radius: Double, tries: Int = 30, randomOnRing: Boolean = true, random: Random = Random.Default, initialPoints: List<Vector2> = listOf(bounds.center), obstacleHashGrids: List<HashGrid> = emptyList(), boundsMapper: (v: Vector2) -> Boolean? = null): List<Vector2>(source)

Creates a random point distribution on a given area Each point gets n tries at generating the next point By default the points are generated along the circumference of r + epsilon to the point They can also be generated on a ring like in the original algorithm from Robert Bridson

Return

a list of points

Parameters

bounds

the rectangular bounds of the area to generate points in

radius

the minimum distance between each point

tries

number of candidates per point

randomOnRing

generate random points on a ring with an annulus from r to 2r

random

a random number generator, default value is Random.Default

initialPoints

a list of points in sampler space, these points will not be tested against r

obstacleHashGrids

a list of obstacles to avoid, defined by points and radii

boundsMapper

a custom function to check if a point is within bounds