tImprove docstring for irregularPacking and add `quality` parameter - Granular.… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 0a7f6cb04c2d44712d6e05f8db0803e53c20e489 | |
parent 7b7df1fcc13b749f31cf95cb962a2c80b5cc9134 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 22 Dec 2017 11:50:10 -0500 | |
Improve docstring for irregularPacking and add `quality` parameter | |
Diffstat: | |
M src/packing.jl | 30 ++++++++++++++++++------------ | |
1 file changed, 18 insertions(+), 12 deletions(-) | |
--- | |
diff --git a/src/packing.jl b/src/packing.jl | |
t@@ -93,7 +93,9 @@ end | |
export irregularPacking! | |
""" | |
irregularPacking!(simulation[, radius_max, radius_min, sample_limit, | |
- thickness, seed, plot_during_packing, verbose) | |
+ padding_factor, binary_radius_search, | |
+ binary_sampling_quality, thickness, seed, | |
+ plot_during_packing, verbose) | |
Generate a dense disc packing in 2D using Poisson disc sampling with O(N) | |
complexity, as described by [Robert Bridson (2007) "Fast Poisson disk sampling | |
t@@ -107,6 +109,15 @@ in arbitrary dimensions"](https://doi.org/10.1145/1278780… | |
* `radius_min::Real`: smallest grain radius to use. | |
* `sample_limit::Integer=30`: number of points to sample around each grain | |
before giving up. | |
+* `padding_factor::Real=0.`: if positive and `binary_radius_search = false`, t… | |
+ add an occasional grain from the current active grain | |
+ (`radius_max*padding_factor`). | |
+* `binary_radius_search::Bool=false`: use a binary radius-sampling procedure to | |
+ fit the largest possible grains into the packing. This option will create | |
+ the highest packing density. | |
+* `binary_sampling_quality::Real=100.`: the quality to enforce during the bina… | |
+ radius search when `binary_radius_search = true`. Larger values create | |
+ denser packings but take longer to complete. | |
* `seed::Integer`: seed value to the pseudo-random number generator. | |
* `plot_during_packing::Bool=false`: produce successive plots as the packing is | |
generated. Requires gnuplot (default). | |
t@@ -116,8 +127,9 @@ function irregularPacking!(simulation::Simulation; | |
radius_max::Real=.1, | |
radius_min::Real=.1, | |
sample_limit::Integer=30, | |
- padding_factor::Real=2., | |
+ padding_factor::Real=0., | |
binary_radius_search::Bool=false, | |
+ binary_sampling_quality::Real=100., | |
thickness::Real=1., | |
seed::Integer=1, | |
plot_during_packing::Bool=false, | |
t@@ -215,8 +227,6 @@ function irregularPacking!(simulation::Simulation; | |
# to a value as large as possible | |
if binary_radius_search | |
- radius_not_found = true | |
- | |
# first test the maximum radius. If unsuccessful, iteratively | |
# find the optimal radius using binary searches | |
if !checkForContacts(simulation, grid, x_candidate, r_candidat… | |
t@@ -226,20 +236,16 @@ function irregularPacking!(simulation::Simulation; | |
r_R = radius_max | |
# size of radius sampling step | |
- dr = (r_R - r_L)/25. | |
- | |
- while radius_not_found | |
+ dr = (r_R - r_L)/binary_sampling_quality | |
- # 2. If L > R, the search terminates as unsuccessful | |
- if r_L > r_R | |
- radius_not_found = false | |
- break | |
- end | |
+ # 2. If L > R, the search terminates as unsuccessful | |
+ while r_L < r_R | |
# 3. Set r to the middle of the current range | |
r_candidate = (r_L + r_R)/2.0 | |
x_candidate = getPositionDistancedFromPoint(T, x_activ… | |
r_active + r_candidate) | |
+ #println("[$r_L, \t $r_candidate, \t $r_R]") | |
# 4. If r < target, set L to r+dr and go to step 2 | |
if checkForContacts(simulation, grid, x_candidate, |