diff --git a/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay01.kt b/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay01.kt index 0c969266..b58da029 100644 --- a/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay01.kt +++ b/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay01.kt @@ -22,7 +22,7 @@ fun main() { val circle = Circle(Vector2(400.0), 250.0) - val points = poissonDiskSampling(width * 1.0, height * 1.0, 30.0) + val points = poissonDiskSampling(drawer.bounds, 30.0) .filter { circle.contains(it) } val delaunay = Delaunay.from(points + circle.contour.equidistantPositions(40)) diff --git a/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay02.kt b/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay02.kt index f6daef84..e994c33a 100644 --- a/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay02.kt +++ b/orx-jvm/orx-triangulation/src/demo/kotlin/DemoDelaunay02.kt @@ -21,7 +21,7 @@ fun main() { val frame = Rectangle.fromCenter(Vector2(400.0), 600.0, 600.0) - val points = poissonDiskSampling(frame.width, frame.height, 50.0).map { it + frame.corner } + val points = poissonDiskSampling(frame, 50.0).map { it + frame.corner } val delaunay = Delaunay.from(points) val halfedges = delaunay.halfedges() diff --git a/orx-jvm/orx-triangulation/src/demo/kotlin/DemoVoronoi01.kt b/orx-jvm/orx-triangulation/src/demo/kotlin/DemoVoronoi01.kt index e53a5a9e..11603a3f 100644 --- a/orx-jvm/orx-triangulation/src/demo/kotlin/DemoVoronoi01.kt +++ b/orx-jvm/orx-triangulation/src/demo/kotlin/DemoVoronoi01.kt @@ -23,7 +23,7 @@ fun main() { val circle = Circle(Vector2(400.0), 250.0) val frame = Rectangle.fromCenter(Vector2(400.0), 600.0, 600.0) - val points = poissonDiskSampling(width * 1.0, height * 1.0, 30.0) + val points = poissonDiskSampling(drawer.bounds, 30.0) .filter { circle.contains(it) } val delaunay = Delaunay.from(points + circle.contour.equidistantPositions(40)) diff --git a/orx-noise/src/commonMain/kotlin/PoissonDisk.kt b/orx-noise/src/commonMain/kotlin/PoissonDisk.kt index 0bfdfd7f..181abb0d 100644 --- a/orx-noise/src/commonMain/kotlin/PoissonDisk.kt +++ b/orx-noise/src/commonMain/kotlin/PoissonDisk.kt @@ -20,11 +20,12 @@ internal const val epsilon = 0.0000001 * They can also be generated on a ring like in the original algorithm from Robert Bridson * * @param bounds the rectangular bounds of the area to generate points in - * @param r the minimum distance between each point + * @param radius the minimum distance between each point * @param tries number of candidates per point * @param randomOnRing generate random points on a ring with an annulus from r to 2r * @param random a random number generator, default value is [Random.Default] * @param initialPoints a list of points in sampler space, these points will not be tested against [r] + * @param obstacleHashGrids a list of obstacles to avoid, defined by points and radii * @param boundsMapper a custom function to check if a point is within bounds * @return a list of points