discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Curved Chain (tentacle) using a series of pill shapes - recursive function?

BH
Benjamin Hill
Wed, Oct 26, 2016 5:10 PM

I'm trying to create an octopus tentacle, but am running into
roadblocks and would love suggestions.

I'm thinking about it like creating a chain of "capsules" (cylinders
with hemisphere ends) - I can create a single link of the chain, and I
can call that function in a loop, and I can even scale the chain links
through the loop, but that system doesn't work when I try to curve the
chain.

I'm wondering if a recursive function would help?  Something like
"draw link from origin, move to other side of the link, scale down
slightly, rotate slightly (this is the part that gets me), recurse"

See image for what I mean.

When I rotate slightly, that means the next link's "other end" isn't a
simple offset, but involves math of the current rotation.  Is there a
way to do it internally to the recursion so I don't have to calculate
it myself?  This would also enable all sorts of neat fractal things.

I'm trying to create an octopus tentacle, but am running into roadblocks and would love suggestions. I'm thinking about it like creating a chain of "capsules" (cylinders with hemisphere ends) - I can create a single link of the chain, and I can call that function in a loop, and I can even scale the chain links through the loop, but that system doesn't work when I try to curve the chain. I'm wondering if a recursive function would help? Something like "draw link from origin, move to other side of the link, scale down slightly, rotate slightly (this is the part that gets me), recurse" See image for what I mean. When I rotate slightly, that means the next link's "other end" isn't a simple offset, but involves math of the current rotation. Is there a way to do it internally to the recursion so I don't have to calculate it myself? This would also enable all sorts of neat fractal things.
NH
nop head
Wed, Oct 26, 2016 5:15 PM

I think you want a recursive module that draws one link, then translates to
the end and rotates a recursive call to itself.

On 26 October 2016 at 18:10, Benjamin Hill benjaminhill@gmail.com wrote:

I'm trying to create an octopus tentacle, but am running into
roadblocks and would love suggestions.

I'm thinking about it like creating a chain of "capsules" (cylinders
with hemisphere ends) - I can create a single link of the chain, and I
can call that function in a loop, and I can even scale the chain links
through the loop, but that system doesn't work when I try to curve the
chain.

I'm wondering if a recursive function would help?  Something like
"draw link from origin, move to other side of the link, scale down
slightly, rotate slightly (this is the part that gets me), recurse"

See image for what I mean.

When I rotate slightly, that means the next link's "other end" isn't a
simple offset, but involves math of the current rotation.  Is there a
way to do it internally to the recursion so I don't have to calculate
it myself?  This would also enable all sorts of neat fractal things.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I think you want a recursive module that draws one link, then translates to the end and rotates a recursive call to itself. On 26 October 2016 at 18:10, Benjamin Hill <benjaminhill@gmail.com> wrote: > I'm trying to create an octopus tentacle, but am running into > roadblocks and would love suggestions. > > I'm thinking about it like creating a chain of "capsules" (cylinders > with hemisphere ends) - I can create a single link of the chain, and I > can call that function in a loop, and I can even scale the chain links > through the loop, but that system doesn't work when I try to curve the > chain. > > I'm wondering if a recursive function would help? Something like > "draw link from origin, move to other side of the link, scale down > slightly, rotate slightly (this is the part that gets me), recurse" > > See image for what I mean. > > When I rotate slightly, that means the next link's "other end" isn't a > simple offset, but involves math of the current rotation. Is there a > way to do it internally to the recursion so I don't have to calculate > it myself? This would also enable all sorts of neat fractal things. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
RP
Ronaldo Persiano
Wed, Oct 26, 2016 6:59 PM

I think you want a recursive module that draws one link, then translates
to the end and rotates a recursive call to itself.

On 26 October 2016 at 18:10, Benjamin Hill benjaminhill@gmail.com wrote:

I'm trying to create an octopus tentacle, but am running into
roadblocks and would love suggestions.

I'm thinking about it like creating a chain of "capsules" (cylinders
with hemisphere ends) - I can create a single link of the chain, and I
can call that function in a loop, and I can even scale the chain links
through the loop, but that system doesn't work when I try to curve the
chain.

I'm wondering if a recursive function would help?  Something like
"draw link from origin, move to other side of the link, scale down
slightly, rotate slightly (this is the part that gets me), recurse"

See image for what I mean.

When I rotate slightly, that means the next link's "other end" isn't a
simple offset, but involves math of the current rotation.  Is there a
way to do it internally to the recursion so I don't have to calculate
it myself?  This would also enable all sorts of neat fractal things.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

A manual example <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/User-Defined_Functions_and_Modules#Recursive_Modules> may help. 2016-10-26 15:15 GMT-02:00 nop head <nop.head@gmail.com>: > I think you want a recursive module that draws one link, then translates > to the end and rotates a recursive call to itself. > > On 26 October 2016 at 18:10, Benjamin Hill <benjaminhill@gmail.com> wrote: > >> I'm trying to create an octopus tentacle, but am running into >> roadblocks and would love suggestions. >> >> I'm thinking about it like creating a chain of "capsules" (cylinders >> with hemisphere ends) - I can create a single link of the chain, and I >> can call that function in a loop, and I can even scale the chain links >> through the loop, but that system doesn't work when I try to curve the >> chain. >> >> I'm wondering if a recursive function would help? Something like >> "draw link from origin, move to other side of the link, scale down >> slightly, rotate slightly (this is the part that gets me), recurse" >> >> See image for what I mean. >> >> When I rotate slightly, that means the next link's "other end" isn't a >> simple offset, but involves math of the current rotation. Is there a >> way to do it internally to the recursion so I don't have to calculate >> it myself? This would also enable all sorts of neat fractal things. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
B
benjaminhill
Wed, Oct 26, 2016 8:58 PM

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.

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.
MS
Mark Schafer
Wed, Oct 26, 2016 10:25 PM

A tail/tentacle design (if controlled by parallel cables) needs to be as
untwistable as possible for it to work.

So solutions with ball joints that allow twisting degrees of freedom
will cause your tail/tentacle to become twisted and non-linear to control.
Ideally you're looking for universal style joints between nodes
alternating up with down.
This way the cables remain in the same orientation as they are manipulated.
E.g.
-
http://hackaday.com/2016/10/21/two-stage-tentacle-mechanisms-part-iii-putting-it-all-together/
- https://www.youtube.com/watch?v=8NQH2B-Mnvg
See second video for a commercial toy I can't find in the marketplace.
(Clic something maybe?)
But its a good guide for what to make. Must keep the rigidity up but the
weight down. It gets very heavy very fast as you add nodes.

Please let us know how you get on...

A tail/tentacle design (if controlled by parallel cables) needs to be as untwistable as possible for it to work. So solutions with ball joints that allow twisting degrees of freedom will cause your tail/tentacle to become twisted and non-linear to control. Ideally you're looking for universal style joints between nodes alternating up with down. This way the cables remain in the same orientation as they are manipulated. E.g. - http://hackaday.com/2016/10/21/two-stage-tentacle-mechanisms-part-iii-putting-it-all-together/ - https://www.youtube.com/watch?v=8NQH2B-Mnvg See second video for a commercial toy I can't find in the marketplace. (Clic something maybe?) But its a good guide for what to make. Must keep the rigidity up but the weight down. It gets very heavy very fast as you add nodes. Please let us know how you get on...
O
otto
Thu, Nov 17, 2016 7:50 PM

See the brand new turtle.scad library at:

https://github.com/ottojas/openscad-affine

It was specifically designed to deal with this kind of problem.

A four link chain program could be written:

use <turtle.scad>
path = [
[go(0)],
[go(20)],
[reSize(.7),turnRight(23)],
[go(20)],
[turnUp(29),reSize(.7)],
[go(20/.7)],
[turnRight(31),reSize(.9)],
[go(20/(.9*.7))]
];
turtlePath(path){sphere(5);}

Regards Otto

On Wed, 26 Oct 2016 10:10:06 -0700
Benjamin Hill benjaminhill@gmail.com wrote:

I'm trying to create an octopus tentacle, but am running into
roadblocks and would love suggestions.

I'm thinking about it like creating a chain of "capsules" (cylinders
with hemisphere ends) - I can create a single link of the chain, and I
can call that function in a loop, and I can even scale the chain links
through the loop, but that system doesn't work when I try to curve the
chain.

I'm wondering if a recursive function would help?  Something like
"draw link from origin, move to other side of the link, scale down
slightly, rotate slightly (this is the part that gets me), recurse"

See image for what I mean.

When I rotate slightly, that means the next link's "other end" isn't a
simple offset, but involves math of the current rotation.  Is there a
way to do it internally to the recursion so I don't have to calculate
it myself?  This would also enable all sorts of neat fractal things.

See the brand new turtle.scad library at: https://github.com/ottojas/openscad-affine It was specifically designed to deal with this kind of problem. A four link chain program could be written: use <turtle.scad> path = [ [go(0)], [go(20)], [reSize(.7),turnRight(23)], [go(20)], [turnUp(29),reSize(.7)], [go(20/.7)], [turnRight(31),reSize(.9)], [go(20/(.9*.7))] ]; turtlePath(path){sphere(5);} Regards Otto On Wed, 26 Oct 2016 10:10:06 -0700 Benjamin Hill <benjaminhill@gmail.com> wrote: > I'm trying to create an octopus tentacle, but am running into > roadblocks and would love suggestions. > > I'm thinking about it like creating a chain of "capsules" (cylinders > with hemisphere ends) - I can create a single link of the chain, and I > can call that function in a loop, and I can even scale the chain links > through the loop, but that system doesn't work when I try to curve the > chain. > > I'm wondering if a recursive function would help? Something like > "draw link from origin, move to other side of the link, scale down > slightly, rotate slightly (this is the part that gets me), recurse" > > See image for what I mean. > > When I rotate slightly, that means the next link's "other end" isn't a > simple offset, but involves math of the current rotation. Is there a > way to do it internally to the recursion so I don't have to calculate > it myself? This would also enable all sorts of neat fractal things.