mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-07 15:26:39 +02:00
refactor and add smooth params
This commit is contained in:
@@ -1,18 +1,25 @@
|
|||||||
use <shape_circle.scad>;
|
use <shape_circle.scad>;
|
||||||
use <experimental/differential_line_growth.scad>;
|
use <experimental/differential_line_growth.scad>;
|
||||||
|
use <midpt_smooth.scad>;
|
||||||
|
|
||||||
$fn = 24;
|
$fn = 24;
|
||||||
r = 20;
|
r = 10;
|
||||||
times = 50;
|
times = 80;
|
||||||
thickness = 2;
|
thickness = 2;
|
||||||
|
smooth = true;
|
||||||
|
smooth_times = 2;
|
||||||
node_option = [
|
node_option = [
|
||||||
0.5, // maxForce
|
0.4, // maxForce
|
||||||
0.7, // maxSpeed
|
0.5, // maxSpeed
|
||||||
12, // separationDistance
|
5, // separationDistance
|
||||||
1.5, // separationCohesionRatio
|
1.2, // separationCohesionRatio
|
||||||
10 // maxEdgeLength
|
4 // maxEdgeLength
|
||||||
];
|
];
|
||||||
|
|
||||||
init_shape = shape_circle(r);
|
init_shape = shape_circle(r);
|
||||||
|
poly = differential_line_growth(init_shape, node_option, times);
|
||||||
|
|
||||||
linear_extrude(thickness)
|
linear_extrude(thickness)
|
||||||
polygon(differential_line_growth(init_shape, node_option, times));
|
polygon(
|
||||||
|
smooth ? midpt_smooth(poly, smooth_times, true) : poly
|
||||||
|
);
|
||||||
|
@@ -89,18 +89,22 @@ function updateAllSeperation(allSeperation, allSeperationFrom_i_1, leng, n) = [
|
|||||||
function differentiate(nodes, leng) =
|
function differentiate(nodes, leng) =
|
||||||
[
|
[
|
||||||
for(i = 0,
|
for(i = 0,
|
||||||
allSep = [for(i = [0:leng - 1]) ZERO_VT],
|
j = 1,
|
||||||
allSeperationFrom_i_1 = allSeperationFrom(nodes, leng, nodes[i], i + 1);
|
allSeperationFrom_i_1 = allSeperationFrom(nodes, leng, nodes[i], j),
|
||||||
i < leng;
|
allSep = [ZERO_VT, each -allSeperationFrom_i_1],
|
||||||
allSep = updateAllSeperation(allSep, allSeperationFrom_i_1, leng, i + 1),
|
running = i < leng;
|
||||||
|
running;
|
||||||
i = i + 1,
|
i = i + 1,
|
||||||
allSeperationFrom_i_1 = i < leng ? allSeperationFrom(nodes, leng, nodes[i], i + 1) : undef
|
j = j + 1,
|
||||||
|
running = i < leng,
|
||||||
|
allSeperationFrom_i_1 = running ? allSeperationFrom(nodes, leng, nodes[i], j) : undef,
|
||||||
|
allSep = running ? updateAllSeperation(allSep, allSeperationFrom_i_1, leng, j) : undef
|
||||||
)
|
)
|
||||||
let(
|
applyForceTo(
|
||||||
seperation_i = sum([allSep[i], each allSeperationFrom_i_1]),
|
nodes[i],
|
||||||
cohesion_i = cohesion(nodes, leng, i)
|
sum([allSep[i], each allSeperationFrom_i_1]),
|
||||||
|
cohesion(nodes, leng, i)
|
||||||
)
|
)
|
||||||
applyForceTo(nodes[i], seperation_i, cohesion_i)
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function _differential_line_growth(nodes) =
|
function _differential_line_growth(nodes) =
|
||||||
|
Reference in New Issue
Block a user