1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/examples/turtle/lsystem3_collection.scad

80 lines
2.4 KiB
OpenSCAD
Raw Normal View History

2022-06-06 13:11:46 +08:00
use <turtle/lsystem3.scad>
use <util/dedup.scad>
use <polyline_join.scad>
2020-04-15 13:35:22 +08:00
2021-08-31 10:02:48 +08:00
for(line = dedup(hilbert_curve())) {
2022-08-17 15:28:21 +08:00
polyline_join(line)
2021-10-08 09:36:01 +08:00
sphere(.25, $fn = 4);
2020-04-15 13:35:22 +08:00
}
2020-04-16 08:41:39 +08:00
function tree1(n = 4, angle = 22.5, leng = 1, heading = 0, start = [0, 0, 0]) =
2020-04-15 13:35:22 +08:00
let(
2020-04-15 13:48:56 +08:00
axiom = "FFFA",
2020-04-15 13:35:22 +08:00
rules = [
2020-04-15 13:48:56 +08:00
["A", "[&FFFA]////[&FFFA]////[&FFFA]"]
2020-04-15 13:35:22 +08:00
]
)
lsystem3(axiom, rules, n, angle, leng, heading, start);
2020-04-18 08:11:00 +08:00
function tree2(n = 5, angle = 18, leng = 1, heading = 0, start = [0, 0, 0]) =
2020-04-16 08:41:39 +08:00
let(
axiom = "BBBBBA",
rules = [
["A", "[++BB[--C][++C][&&C][^^C]A]/////+BBB[--C][++C][&&C][^^C]A"],
["B", "\\\\B"],
["C", ""]
]
)
lsystem3(axiom, rules, n, angle, leng, heading, start, forward_chars = "ABC");
2020-04-16 08:36:53 +08:00
function plant(n = 4, angle = 30, leng = 1, heading = 0, start = [0, 0, 0]) =
let(
axiom = "A",
rules = [
["A", "B[+A]\\\\\\\\[+A]\\\\\\\\[+A]\\\\\\\\BA"],
["B", "BB"],
["B", "A/B"]
]
)
2022-05-08 10:37:25 +08:00
lsystem3(axiom, rules, n, angle, leng, heading, start, forward_chars = "AB", rule_prs = [1, .5, .5]);
2020-04-16 08:36:53 +08:00
2020-04-15 13:35:22 +08:00
function hilbert_curve(n = 3, angle = 90, leng = 1, heading = 0, start = [0, 0, 0]) =
let(
axiom = "A",
rules = [
2020-04-18 08:11:00 +08:00
["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"],
["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"],
["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"],
["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"]
2020-04-15 13:35:22 +08:00
]
)
2020-04-15 14:01:22 +08:00
lsystem3(axiom, rules, n, angle, leng, heading, start);
2020-04-15 14:05:35 +08:00
function fern(n = 8, angle = 4, leng = 1, heading = 0, start = [0, 0, 0]) =
2020-04-15 14:01:22 +08:00
let(
axiom = "EEEA",
rules = [
["A", "[++++++++++++++EC]B^+B[--------------ED]B+BA"],
["C", "[---------EE][+++++++++EE]B&&+C"],
["D", "[---------EE][+++++++++EE]B&&-D"]
]
)
2020-04-16 08:25:32 +08:00
lsystem3(axiom, rules, n, angle, leng, heading, start, forward_chars = "ABCDE");
2020-04-16 08:26:06 +08:00
function vine(n = 3, angle = 18, leng = 1, heading = 0, start = [0, 0, 0]) =
2020-04-16 08:25:32 +08:00
let(
axiom = "--F",
rules = [
2020-04-16 08:31:46 +08:00
["F", "/F[++F]-\\F[--F]+//F"]
2020-04-16 08:25:32 +08:00
]
)
2020-04-16 08:28:41 +08:00
lsystem3(axiom, rules, n, angle, leng, heading, start);
function spring(n = 8, angle = 12, leng = 1, heading = 0, start = [0, 0, 0]) =
let(
axiom = "F",
rules = [
["F", "F-^F"]
]
)
2020-04-16 08:25:32 +08:00
lsystem3(axiom, rules, n, angle, leng, heading, start);