[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() {               
sphere(r = radius);                                next_radius = idx+1 <
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])               
sphere(r = next_radius);                */            }           
translate([-radius,radius/2,-radius])            cube([radius*2, radius,
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.   
chainlink(chain_dna);}




--
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...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20161026/15bbb77f/attachment-0002.html>


More information about the Discuss mailing list