mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
rand startr
This commit is contained in:
parent
e66aeccd33
commit
b384817b98
@ -1,12 +1,12 @@
|
|||||||
use <../../matrix/m_replace.scad>
|
use <../../matrix/m_replace.scad>
|
||||||
use <../../util/every.scad>
|
use <../../util/every.scad>
|
||||||
|
|
||||||
function sampling(size, r, start, k) =
|
function sampling(size, r, start, k, sd) =
|
||||||
let(
|
let(
|
||||||
w = r / sqrt(2),
|
w = r / sqrt(2),
|
||||||
rows = floor(size.y / w),
|
rows = floor(size.y / w),
|
||||||
columns = floor(size.x / 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],
|
active = [pt],
|
||||||
px = floor(pt.x / w),
|
px = floor(pt.x / w),
|
||||||
py = floor(pt.y / w),
|
py = floor(pt.y / w),
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use <_impl/_pp_poisson2.scad>
|
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(
|
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 = [
|
samples = [
|
||||||
for(row = sampling_grid(s), sample = row)
|
for(row = sampling_grid(s), sample = row)
|
||||||
if(!is_undef(sample)) sample
|
if(!is_undef(sample)) sample
|
||||||
|
Loading…
x
Reference in New Issue
Block a user