1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-16 21:58:26 +01:00

rand startr

This commit is contained in:
Justin Lin 2022-07-02 17:03:14 +08:00
parent e66aeccd33
commit b384817b98
2 changed files with 5 additions and 4 deletions

View File

@ -1,12 +1,12 @@
use <../../matrix/m_replace.scad>
use <../../util/every.scad>
function sampling(size, r, start, k) =
function sampling(size, r, start, k, sd) =
let(
w = r / sqrt(2),
rows = floor(size.y / w),
columns = floor(size.x / w),
pt = is_undef(start) ? size / 2 : start,
pt = is_undef(start) ? [rands(0, size.x, 1, sd)[0], rands(0, size.y, 1, sd + 1)[0]] : start,
active = [pt],
px = floor(pt.x / w),
py = floor(pt.y / w),

View File

@ -1,8 +1,9 @@
use <_impl/_pp_poisson2.scad>
function pp_poisson2(size, r, start = undef, k = 30, seed = undef, history = false) =
function pp_poisson2(size, r, start, k = 30, seed = undef, history = false) =
let(
s = _pp_poisson(sampling(size, r, start, k), is_undef(seed) ? floor(rands(0, 1000, 1)[0]) : seed),
sd = is_undef(seed) ? floor(rands(0, 1000, 1)[0]) : seed,
s = _pp_poisson(sampling(size, r, start, k, sd), sd),
samples = [
for(row = sampling_grid(s), sample = row)
if(!is_undef(sample)) sample