diff --git a/examples/turtle/hilbert_curve_drawing.scad b/examples/turtle/hilbert_curve_drawing.scad new file mode 100644 index 00000000..7a0b5e4e --- /dev/null +++ b/examples/turtle/hilbert_curve_drawing.scad @@ -0,0 +1,29 @@ +use ; +use ; +use ; +use ; + +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]); \ No newline at end of file