Created
May 25, 2015 20:14
-
-
Save Yona-Appletree/ecf74d65f7cc09eaad46 to your computer and use it in GitHub Desktop.
Turtle shape function for openSCAD
This file contains 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
function sum(parts, i=0) = (i < len(parts)-1) ? (parts[i] + sum(parts, i+1)) : parts[i]; | |
function turtlePoints( | |
commands, | |
i = 0, | |
prev = [0,0] | |
) = let( | |
s = sum(commands[i]), | |
current = i == 0 ? s : (prev + s) | |
) concat( | |
[current], | |
(i < len(commands)-1) ? turtlePoints(commands, i+1, current) : [] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment