1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-12 17:54:18 +02:00

isolate axiom

This commit is contained in:
Justin Lin
2020-04-14 15:41:02 +08:00
parent 498f9f3e18
commit 05145694d9
3 changed files with 95 additions and 95 deletions

View File

@@ -13,287 +13,287 @@ for(line = plant()) {
function tree(n = 2, angle = 36, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "F[+FF][-FF]F[-F][+F]F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function plant(n = 4, angle = 25, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "X"],
axiom = "X",
rules = [
["X", "F+[[X]-X]-F[-FX]+X"],
["F", "FF"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_curve(n = 4, angle = 60, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "F-F++F-F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_curve_3(n = 3, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F-F-F-F"],
axiom = "F-F-F-F",
rules = [
["F", "FF-F+F-F-FF"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_snowflake(n = 4, angle = 60, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F++F++F"],
axiom = "F++F++F",
rules = [
["F", "F-F++F-F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_quadratic(n = 3, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F-F-F-F"],
axiom = "F-F-F-F",
rules = [
["F", "FF-F-F-F-F-F+F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_quadratic_type1(n = 4, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "F-F+F+F-F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_quadratic_type2(n = 4, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "F-F+F+FF-F-F+F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function koch_star(n = 4, angle = 60, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F++F++F"],
axiom = "F++F++F",
rules = [
["F", "F+F--F+F"]
]
)
lsystem2(rule, n, angle, leng, heading, start, "6789");
lsystem2(axiom, rules, n, angle, leng, heading, start, "6789");
function dragon_curve(n = 10, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "FX"],
axiom = "FX",
rules = [
["X", "X+YF+"],
["Y", "-FX-Y"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function twin_dragon_curve(n = 8, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "FX+FX+"],
axiom = "FX+FX+",
rules = [
["X", "X+YF"],
["Y", "Y=FX-Y"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function hilbert_curve(n = 5, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "A"],
axiom = "A",
rules = [
["A", "-BF+AFA+FB-"],
["B", "+AF-BFB-FA+"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function moore_curve(n = 4, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "LFL+F+LFL"],
axiom = "LFL+F+LFL",
rules = [
["L", "-RF+LFL+FR-"],
["R", "+LF-RFR-FL+"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function peano_curve(n = 3, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "L"],
axiom = "L",
rules = [
["L", "LFRFL-F-RFLFR+F+LFRFL"],
["R", "RFLFR+F+LFRFL-F-RFLFR"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function gosper_curve(n = 4, angle = 60, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "A"],
axiom = "A",
rules = [
["A", "A-B--B+A++AA+B-"],
["B", "+A-BB--B-A++A+B"]
]
)
lsystem2(rule, n, angle, leng, heading, start, "AB");
lsystem2(axiom, rules, n, angle, leng, heading, start, "AB");
function gosper_star(n = 2, angle = 60, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "X-X-X-X-X-X"],
axiom = "X-X-X-X-X-X",
rules = [
["X", "FX+YF++YF-FX--FXFX-YF+"],
["Y", "-FX+YFYF++YF+FX--FX-FY"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function levy_c_curve(n = 8, angle = 45, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "+F--F+"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function island_curve(n = 2, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F-F-F-F"],
axiom = "F-F-F-F",
rules = [
["F", "F-M+FF-F-FF-FM-FF+M-FF+F+FF+FM+FFF"],
["M", "MMMMMM"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function sierpinski_triangle(n = 5, angle = 120, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F-G-G"],
axiom = "F-G-G",
rules = [
["F", "F-G+F+G-F"],
["G", "GG"]
]
)
lsystem2(rule, n, angle, leng, heading, start, "FG");
lsystem2(axiom, rules, n, angle, leng, heading, start, "FG");
function sierpinski_arrowhead(n = 6, angle = 60, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "XF"],
axiom = "XF",
rules = [
["X", "YF+XF+Y"],
["Y", "XF-YF-X"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function sierpinski_square(n = 8, angle = 45, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "L--F--L--F"],
axiom = "L--F--L--F",
rules = [
["L", "+R-F-R+"],
["R", "-L+F+L-"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function terdragon(n = 5, angle = 120, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "F+F-F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function pentadendrite(n = 2, angle = 72, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F-F-F-F-F"],
axiom = "F-F-F-F-F",
rules = [
["F", "F-F-F++F+F-F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function icy(n = 2, angle = 90, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F+F+F+F"],
axiom = "F+F+F+F",
rules = [
["F", "FF+F++F+F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function round_star(n = 3, angle = 77, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "F++F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function penrose_tiling(n = 2, angle = 36, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "[7]++[7]++[7]++[7]++[7]"],
axiom = "[7]++[7]++[7]++[7]++[7]",
rules = [
["6", "81++91----71[-81----61]++"],
["7", "+81--91[---61--71]+"],
["8", "-61++71[+++81++91]-"],
["9", "--81++++61[+91++++71]--71"]
]
)
lsystem2(rule, n, angle, leng, heading, start, "6789");
lsystem2(axiom, rules, n, angle, leng, heading, start, "6789");
function bush(n = 3, angle = 16, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "++++F"],
axiom = "++++F",
rules = [
["F", "FF-[-F+F+F]+[+F-F-F]"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function pentigree(n = 3, angle = 72, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F-F-F-F-F"],
axiom = "F-F-F-F-F",
rules = [
["F", "F-F++F+F-F-F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function penrose_snowflake(n = 3, angle = 18, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F----F----F----F----F"],
axiom = "F----F----F----F----F",
rules = [
["F", "F----F----F----------F++F----F"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);
function weed(n = 6, angle = 22.5, leng = 1, heading = 0, start = [0, 0]) =
let(
rule = [
["S", "F"],
axiom = "F",
rules = [
["F", "FF-[XY]+[XY]"],
["X", "+FY"],
["Y", "-FX"]
]
)
lsystem2(rule, n, angle, leng, heading, start);
lsystem2(axiom, rules, n, angle, leng, heading, start);

View File

@@ -33,9 +33,9 @@ function _derive1(base, rules) = _join([
function _derive(base, rules, n, i = 0) =
i == n ? base : _derive(_derive1(base, rules), rules, n, i + 1);
function _lsystem2_derive(rules, n, rules_pr) =
is_undef(rules_pr) ? _derive(rules[0][1], rules, n) :
rand() <= rules_pr[0] ? _derive_p(rules[0][1], rules, rules_pr, n) : "";
function _lsystem2_derive(axiom, rules, n, rules_pr) =
is_undef(rules_pr) ? _derive(axiom, rules, n) :
_derive_p(axiom, rules, rules_pr, n);
function _next_stack(t, code, stack) =
code == "[" ? concat([t], stack) :

View File

@@ -1,9 +1,9 @@
use <experimental/_impl/_lsystem2_impl.scad>;
use <turtle/turtle2d.scad>;
function lsystem2(rules, n, angle, leng = 1, heading = 0, start = [0, 0], forward_chars = "F", rules_pr) =
function lsystem2(axiom, rules, n, angle, leng = 1, heading = 0, start = [0, 0], forward_chars = "F", rules_pr) =
let(
derived = _lsystem2_derive(rules, n, rules_pr),
derived = _lsystem2_derive(axiom, rules, n, rules_pr),
codes = forward_chars == "F" ? derived : _join([
for(c = derived)
let(idx = search(c, forward_chars))