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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

benjaminhill
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Screen Shot 2016-10-26 at 10.07.08 AM.png (37K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

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

Ronaldo
A manual example may help.

2016-10-26 15:15 GMT-02:00 nop head <[hidden email]>:
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

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

benjaminhill
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);
}
Reply | Threaded
Open this post in threaded view
|

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

Neon22
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...



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

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

PaulMurrayCbr
This post has NOT been accepted by the mailing list yet.
In reply to this post by benjaminhill
My scad syntax is a bit rusty, but to draw a tentacle of N segments that goes vertically up from 0,0,0:

union() {
  sphere(3);
  if(N > 0) {
    cylinder from 0,0,0 to 0,0,10, radius 3
    translate(0,0,10) {
      rotate(a small rotation)
      scale(.9)
      tentacle(n-1);
    }    
  }
}

Reply | Threaded
Open this post in threaded view
|

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

ottojas
In reply to this post by benjaminhill
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org