mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 22:28:16 +01:00
refactor: vector addition
This commit is contained in:
parent
2b58eb7528
commit
6250cce455
@ -11,13 +11,12 @@
|
||||
module vrn2_space(size, grid_w, seed, spacing = 1, r = 0, delta = 0, chamfer = false, region_type = "square") {
|
||||
function cell_pt(fcord, seed, x, y, gw, gh) =
|
||||
let(
|
||||
nx = fcord.x + x,
|
||||
ny = fcord.y + y,
|
||||
sd_x = (nx + gw) % gw,
|
||||
sd_y = (ny + gh) % gh,
|
||||
nv = fcord + [x, y],
|
||||
sd_x = (nv.x + gw) % gw,
|
||||
sd_y = (nv.y + gh) % gh,
|
||||
sd_base = abs(sd_x + sd_y * grid_w)
|
||||
)
|
||||
([nx, ny] + rands(0.1, 0.9, 2, seed_value = seed + sd_base)) * grid_w;
|
||||
(nv + rands(0.1, 0.9, 2, seed_value = seed + sd_base)) * grid_w;
|
||||
|
||||
// 9-nearest-neighbor
|
||||
function _neighbors(fcord, seed, grid_w, gw, gh) =
|
||||
|
@ -16,12 +16,10 @@ module vrn3_space(size, grid_w, seed, spacing = 1) {
|
||||
let(range = [-1:1])
|
||||
for(z = range, y = range, x = range)
|
||||
let(
|
||||
nx = fcord.x + x,
|
||||
ny = fcord.y + y,
|
||||
nz = fcord.z + z,
|
||||
sd_base = abs(nx + ny * grid_w + nz * grid_w * grid_w)
|
||||
nv = fcord + [x, y, z],
|
||||
sd_base = abs(nv * [1, grid_w, grid_w ^ 2])
|
||||
)
|
||||
([nx, ny, nz] + rands(0.1, 0.9, 3, seed_value = seed + sd_base)) * grid_w
|
||||
(nv + rands(0.1, 0.9, 3, seed_value = seed + sd_base)) * grid_w
|
||||
];
|
||||
|
||||
space_size = grid_w * 3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user