Skip to content

Instantly share code, notes, and snippets.

@Yona-Appletree
Created May 25, 2015 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yona-Appletree/ecf74d65f7cc09eaad46 to your computer and use it in GitHub Desktop.
Save Yona-Appletree/ecf74d65f7cc09eaad46 to your computer and use it in GitHub Desktop.
Turtle shape function for openSCAD
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