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

82 lines
2.4 KiB
OpenSCAD
Raw Normal View History

2020-05-03 08:27:06 +08:00
use <turtle/lsystem3.scad>;
2020-04-15 13:35:22 +08:00
use <hull_polyline3d.scad>;
2020-04-18 08:11:00 +08:00
for(line = hilbert_curve()) {
2020-04-15 13:35:22 +08:00
hull_polyline3d(
[line[0], line[1]],
2021-02-18 10:45:44 +08:00
diameter = 0.5,
2020-04-15 13:35:22 +08:00
$fn = 4
);
}
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"]
]
)
2020-04-16 09:02:56 +08:00
lsystem3(axiom, rules, n, angle, leng, heading, start, forward_chars = "AB", rules_pr = [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);