discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Non-Linear Transformations

R
runsun
Wed, Nov 18, 2015 10:11 PM

Thx, ctchin. That's neat.

Since I spent most of design in polyhedron, what I am most interested in is
how two polyhedrons join/branch.


$  Runsun Pan, PhD

$ libs:

doctest ,

faces ( git ),

offline doc ( git ),

runscad.py( 1 , 2 , git );

$ tips:

hash( 1 , 2 ),

sweep ,

var( 1 , 2 ),

lerp ,

animGif ,

precision

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14633.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Thx, ctchin. That's neat. Since I spent most of design in polyhedron, what I am most interested in is how two polyhedrons join/branch. ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var( 1 , 2 ), lerp , animGif , precision -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14633.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Wed, Nov 18, 2015 10:21 PM

btw, ctchin, posts in this thread,  Bent rod
http://forum.openscad.org/Bent-rod-tp14003p14004.html  , might give some
ideas. Among them, my version:

http://forum.openscad.org/file/n14004/20150925_bent_pipe.png


$  Runsun Pan, PhD

$ libs:

doctest ,

faces ( git ),

offline doc ( git ),

runscad.py( 1 , 2 , git );

$ tips:

hash( 1 , 2 ),

sweep ,

var( 1 , 2 ),

lerp ,

animGif ,

precision

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14634.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

btw, ctchin, posts in this thread, Bent rod <http://forum.openscad.org/Bent-rod-tp14003p14004.html> , might give some ideas. Among them, my version: <http://forum.openscad.org/file/n14004/20150925_bent_pipe.png> ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var( 1 , 2 ), lerp , animGif , precision -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14634.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Thu, Nov 19, 2015 2:12 AM

ctchin wrote

Branching also becomes obvious.

Parkinbot wrote

If I was a pipe I'd prefer to be modelled like this (works for any angle

):

I was playing with these two approaches and tried to make a generalized tree
branching with fillets between.

Its working well for direct code but I wanted to use a list and a for loop.
Alas the for loop does an implied union() and so the children() is not
working.
My brain has frozen on how to get around it.
E.g. I have this: (images in forum)

use <fillet.scad>
// from clothbot
// - https://github.com/clothbot/ClothBotCreations/tree/master/utilities

d0 = 10;
h1 = 30;
h2 = 20;
angle = -66;

// Parkinbot approach (filleted)
translate([30,20,0])
fillet(r=2,steps=2) {
rotate([angle,0,0])
cylinder(h1, d=d0);
cylinder(h2, d=d0);
// join
color("red")
sphere(d0/2);
}

// ctchin approach (filleted)
translate([30,-20,0])
fillet(r=2,steps=4) {
rotate([angle,0,0]) cylinder(h1, d=d0);
cylinder(h2, d=d0);
// join
color("red")
intersection() {
rotate([angle,0,0])
translate([0,0,-2d0])
cylinder(d=d0,h=2
d0);
translate([0,0,-2d0])
cylinder(d=d0,h=2
d0);
}
}

//-----------------------------
// Each branch is a cylinder with [diameter, startpt, anglexyz, length]
//    - startpt, anglexyz are triplets
// generalize later to use shape profile instead of circle (cylinder)
// (one day alllow random variation in deformation along length of the
branch object)
branches = [
[10, [0,0,0], [0,0,0], 40],
[10, [0,0,0], [45,0,0], 40],
[5,  [0,0,30], [66,-22,0], 33],
[5,  [0,0,25], [66,-22,250], 33],
];

module make_tree(branches=branches, blend=4, method="round") {
// add round/sharp in here
// how to get around implied union of for() ?
fillet(r=2,steps=4) {
for (b=branches) {
dia = b[0];
start = b[1];
angle = b[2];
dist = b[3];
translate(start)
rotate(angle)
cylinder(h=dist, d=dia);
}
}
}

make_tree();

To get a result like this:
http://forum.openscad.org/file/n14635/branches_5.png

How do I pass all the results of the for loop to fillet() as children ?

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14635.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

ctchin wrote > Branching also becomes obvious. Parkinbot wrote > If I was a pipe I'd prefer to be modelled like this (works for any angle > ): I was playing with these two approaches and tried to make a generalized tree branching with fillets between. Its working well for direct code but I wanted to use a list and a for loop. Alas the for loop does an implied union() and so the children() is not working. My brain has frozen on how to get around it. E.g. I have this: (images in forum) use <fillet.scad> // from clothbot // - https://github.com/clothbot/ClothBotCreations/tree/master/utilities d0 = 10; h1 = 30; h2 = 20; angle = -66; // Parkinbot approach (filleted) translate([30,20,0]) fillet(r=2,steps=2) { rotate([angle,0,0]) cylinder(h1, d=d0); cylinder(h2, d=d0); // join color("red") sphere(d0/2); } // ctchin approach (filleted) translate([30,-20,0]) fillet(r=2,steps=4) { rotate([angle,0,0]) cylinder(h1, d=d0); cylinder(h2, d=d0); // join color("red") intersection() { rotate([angle,0,0]) translate([0,0,-2*d0]) cylinder(d=d0,h=2*d0); translate([0,0,-2*d0]) cylinder(d=d0,h=2*d0); } } //----------------------------- // Each branch is a cylinder with [diameter, startpt, anglexyz, length] // - startpt, anglexyz are triplets // generalize later to use shape profile instead of circle (cylinder) // (one day alllow random variation in deformation along length of the branch object) branches = [ [10, [0,0,0], [0,0,0], 40], [10, [0,0,0], [45,0,0], 40], [5, [0,0,30], [66,-22,0], 33], [5, [0,0,25], [66,-22,250], 33], ]; module make_tree(branches=branches, blend=4, method="round") { // add round/sharp in here // how to get around implied union of for() ? fillet(r=2,steps=4) { for (b=branches) { dia = b[0]; start = b[1]; angle = b[2]; dist = b[3]; translate(start) rotate(angle) cylinder(h=dist, d=dia); } } } make_tree(); To get a result like this: <http://forum.openscad.org/file/n14635/branches_5.png> How do I pass all the results of the for loop to fillet() as children ? -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14635.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Nov 19, 2015 2:17 AM

Usually, an (implicit) union joins overlapping or matching (there is always a
numerical error!) objects. This happens also with polyhedrons. If you
calculate your own polyhedrons (your example doesn't look so) just provide
some very small overlapping.
BUT, when I try to implement your example along the "broadway", say, like
this:

I'm getting this:
http://forum.openscad.org/file/n14636/weird.png

I remember that the convexity parameter of linear_extrude() never worked
properly with me, so in the end to get more out of it I implemented a
fullblown library to bypass it on the basis of hull(). Just have a look at:
http://www.thingiverse.com/thing:648813

runsun wrote

btw, ctchin, posts in this thread,
Bent rod http://forum.openscad.org/Bent-rod-tp14003p14004.html
, might give some ideas. Among them, my version:

http://forum.openscad.org/file/n14004/20150925_bent_pipe.png

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14636.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Usually, an (implicit) union joins overlapping or matching (there is always a numerical error!) objects. This happens also with polyhedrons. If you calculate your own polyhedrons (your example doesn't look so) just provide some very small overlapping. BUT, when I try to implement your example along the "broadway", say, like this: I'm getting this: <http://forum.openscad.org/file/n14636/weird.png> I remember that the convexity parameter of linear_extrude() never worked properly with me, so in the end to get more out of it I implemented a fullblown library to bypass it on the basis of hull(). Just have a look at: http://www.thingiverse.com/thing:648813 runsun wrote > btw, ctchin, posts in this thread, > Bent rod <http://forum.openscad.org/Bent-rod-tp14003p14004.html> > , might give some ideas. Among them, my version: <http://forum.openscad.org/file/n14004/20150925_bent_pipe.png> -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14636.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Nov 19, 2015 3:01 AM

@Neon: If something is against you, better try to befriend it.
OK, I know, this is more a work around than the solution you are seeking,
but I'm afraid you won't get rid of the implicit union.

http://forum.openscad.org/file/n14637/tree.png

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14637.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

@Neon: If something is against you, better try to befriend it. OK, I know, this is more a work around than the solution you are seeking, but I'm afraid you won't get rid of the implicit union. <http://forum.openscad.org/file/n14637/tree.png> -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14637.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Thu, Nov 19, 2015 5:10 AM

ok that's pretty nice.
I guess the disadvantage is the exponential work done as each fillet is
applied to the growing object and one new part.
Maybe in OpenSCAD2 .
Thanks...

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14638.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

ok that's pretty nice. I guess the disadvantage is the exponential work done as each fillet is applied to the growing object and one new part. Maybe in OpenSCAD2 . Thanks... -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14638.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
ctchin
Thu, Nov 19, 2015 6:20 AM

Parkinbot wrote

  • SMACK FOREHEAD *

Doh of course you are right!  My brain was stuck from a previous design for
which the sphere wouldn't work, but for cylinders of course a spherical
elbow is easier and prettier.

THANKS!

(anyway the model with the ugly angular joints already went and come back
from the printer)

http://forum.openscad.org/file/n14639/bifurcation-printed.jpg

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14639.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Parkinbot wrote * SMACK FOREHEAD * Doh of course you are right! My brain was stuck from a previous design for which the sphere wouldn't work, but for cylinders of course a spherical elbow is easier and prettier. THANKS! (anyway the model with the ugly angular joints already went and come back from the printer) <http://forum.openscad.org/file/n14639/bifurcation-printed.jpg> -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14639.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Nov 19, 2015 1:03 PM

You are right. A better solution would be the following approach. I didn't
present it, as I forgot how to express a partial array (Was it ever possible
in OpenSCAD to express a partial array like branches[2:4] ) Overcoming this
obstacle with the tail function, this is your proper and fast solution
ver2.0:

(By the way: a nice approach .)

Neon22 wrote

I guess the disadvantage is the exponential work done as each fillet is
applied to the growing object and one new part.

--
View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14644.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

You are right. A better solution would be the following approach. I didn't present it, as I forgot how to express a partial array (Was it ever possible in OpenSCAD to express a partial array like branches[2:4] ) Overcoming this obstacle with the tail function, this is your proper and fast solution ver2.0: (By the way: a nice approach .) Neon22 wrote > I guess the disadvantage is the exponential work done as each fillet is > applied to the growing object and one new part. -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14644.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MS
Mark Schafer
Thu, Nov 19, 2015 10:18 PM

Yes I used this pattern
for (i=[1:len(branches)]) {
b = branches[i];

On 11/20/2015 2:03 AM, Parkinbot wrote:

You are right. A better solution would be the following approach. I didn't
present it, as I forgot how to express a partial array (Was it ever possible
in OpenSCAD to express a partial array like branches[2:4] ) Overcoming this
obstacle with the tail function, this is your proper and fast solution
ver2.0:

(By the way: a nice approach .)

Yes I used this pattern for (i=[1:len(branches)]) { b = branches[i]; On 11/20/2015 2:03 AM, Parkinbot wrote: > You are right. A better solution would be the following approach. I didn't > present it, as I forgot how to express a partial array (Was it ever possible > in OpenSCAD to express a partial array like branches[2:4] ) Overcoming this > obstacle with the tail function, this is your proper and fast solution > ver2.0: > > (By the way: a nice approach .) > >
DM
doug moen
Thu, Nov 19, 2015 11:04 PM

parkinbot: Was it ever possible in OpenSCAD to express a partial array like
branches[2:4]?

Currently you must write
[for(i=[2:4])branches[i]]

Many people have asked for a more direct 'slice' operator, but we don't
have one yet. Multiple syntaxes have been proposed.

On 19 November 2015 at 08:03, Parkinbot rudolf@parkinbot.com wrote:

You are right. A better solution would be the following approach. I didn't
present it, as I forgot how to express a partial array (Was it ever
possible
in OpenSCAD to express a partial array like branches[2:4] ) Overcoming this
obstacle with the tail function, this is your proper and fast solution
ver2.0:

(By the way: a nice approach .)

Neon22 wrote

I guess the disadvantage is the exponential work done as each fillet is
applied to the growing object and one new part.

--
View this message in context:
http://forum.openscad.org/Non-Linear-Transformations-tp14539p14644.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

parkinbot: Was it ever possible in OpenSCAD to express a partial array like branches[2:4]? Currently you must write [for(i=[2:4])branches[i]] Many people have asked for a more direct 'slice' operator, but we don't have one yet. Multiple syntaxes have been proposed. On 19 November 2015 at 08:03, Parkinbot <rudolf@parkinbot.com> wrote: > You are right. A better solution would be the following approach. I didn't > present it, as I forgot how to express a partial array (Was it ever > possible > in OpenSCAD to express a partial array like branches[2:4] ) Overcoming this > obstacle with the tail function, this is your proper and fast solution > ver2.0: > > (By the way: a nice approach .) > > > > > Neon22 wrote > > I guess the disadvantage is the exponential work done as each fillet is > > applied to the growing object and one new part. > > > > > > -- > View this message in context: > http://forum.openscad.org/Non-Linear-Transformations-tp14539p14644.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > >