# [OpenSCAD] Curved Chain (tentacle) using a series of pill shapes - recursive function?

benjaminhill benjaminhill at gmail.com
Wed Oct 26 16:58:09 EDT 2016

```That was excellent advice, thank you!
\$fn=50;BASE_HEIGHT = 1;// Angle (curl), Radius (thickness), Height
(length)chain_dna = [     [ 15, .9, 1 ], [ 15, .8, 1 ], [ 15, .7, 1 ],  [
-15, .6, 1 ],     [ -15, .5, 1 ], [-15, .4, .8], [-15, .38, .6 ], [-30, .35,
.4],     [-30, .33, .4], [-30, .3, .4], [-30, .28, .4], [-30, .26,
.4]];module chainlink(dna, idx = 0) {    if (idx +1 < len(dna)) {
angle = dna[idx][0];        radius = dna[idx][1];        height =
dna[idx][2];        difference() {            union() {
len(dna) ? dna[idx+1][1] : dna[idx][1];                cylinder(r1 = radius,
r2 = next_radius, h = BASE_HEIGHT * height);
/*                translate([0,0,BASE_HEIGHT * height])
height+(2*radius)]);        }                translate([0, 0, BASE_HEIGHT *
height])        rotate([angle,0,0])        chainlink(dna, idx + 1);
}}union() {    // Call the module to create the stacked cylinders.

--
View this message in context: http://forum.openscad.org/Curved-Chain-tentacle-using-a-series-of-pill-shapes-recursive-function-tp18808p18811.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...