Created
October 28, 2015 01:11
-
-
Save dyama/5d9879fc20ffeccb32bf to your computer and use it in GitHub Desktop.
siren sample scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/siren | |
# coding: utf-8 | |
# | |
# fractal tree | |
# | |
$start_len = 100.0 | |
def tree(cur_pt, dir, len) | |
nxt_pt = cur_pt + dir * len | |
edges = [ Build::line(cur_pt, nxt_pt) ] | |
len *= 0.75 | |
if len > $start_len / 10.0 | |
edges.concat tree(nxt_pt, dir.rotate(Vec::ydir, 30.0.to_rad), len) | |
edges.concat tree(nxt_pt, dir.rotate(Vec::ydir, -30.0.to_rad), len) | |
end | |
return edges | |
end | |
lines = tree(Vec::origin, Vec::zdir, $start_len) | |
comp = Build.compound lines | |
IGES.save [comp], "tree.igs" | |
puts "done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment