mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-01 04:20:27 +02:00
add hilbert_curve_drawing
This commit is contained in:
29
examples/turtle/hilbert_curve_drawing.scad
Normal file
29
examples/turtle/hilbert_curve_drawing.scad
Normal file
@@ -0,0 +1,29 @@
|
||||
use <bezier_smooth.scad>;
|
||||
use <hull_polyline3d.scad>;
|
||||
use <util/dedup.scad>;
|
||||
use <turtle/lsystem3.scad>;
|
||||
|
||||
thickness = 0.3;
|
||||
corner_r = 0.5;
|
||||
|
||||
lines = hilbert_curve();
|
||||
hilbert_path = dedup(
|
||||
concat(
|
||||
[for(line = lines) line[0]],
|
||||
[lines[len(lines) - 1][1]])
|
||||
);
|
||||
smoothed_hilbert_path = bezier_smooth(hilbert_path, corner_r);
|
||||
|
||||
hull_polyline3d(smoothed_hilbert_path, thickness = thickness);
|
||||
|
||||
function hilbert_curve() =
|
||||
let(
|
||||
axiom = "A",
|
||||
rules = [
|
||||
["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//"]
|
||||
]
|
||||
)
|
||||
lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]);
|
Reference in New Issue
Block a user