discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Non-Linear Transformations

C
ctchin
Wed, Nov 18, 2015 4:28 AM

Parkinbot wrote

Having followed this thread now for a while, I can see that obviously many
of us are trying to merge stuff implemented in several languages with
OpenSCAD and vice versa. One might call it loony stuff, but isn't a
programming language meant for being able to do loony stuff, without being
loony itself?
...
Loony stuff, especially when you think about using it n-dimensional for
other shapes like airfoils, gears and so on. But isn't it, what
programmers want to do and why programmers are programmers and not users?

Well not un-deliberately, my wording loony was a bit vague.  I love the NACA
you created and Joukowski (that's how my fluid mech book spells it) airfoil
Trygon created.  My point about loony isn't about amazing and beautiful
things that the users created (or better: may create) but too often some
users have some vague idea and expect OTHER people to do the hard work for
them.

In general conformal mapping is a powerful branch of math that make some
very useful shapes.

Especially you and Trygon's code showed the existing OpenSCAD commands are
powerful enough if only more people put some hard work into it.  I'd invite
you to put some of your code into a library that I'm advocating.

Now yes... you have been convincing there are room to expand some sort of
distortion, transformation or something in OpenSCAD (like I hinted at, I've
been frustrated with it myself).  But I'm not sure you have been convincing
enough that the core team should take on this task as priority, soon.

OpenSCAD is open source, there's an open invitation on the main website to
add new features.  This "debate" would be a lot more substantial if someone
create a new transformation and make a pitch that it should be included into
the main branch.

After seeing some substantive response to the "loony" challenge... I was
thinking how to enable some of the "loony" ideas to progress without
unwanted side-effects.  The answer seems obvious, create a plug-in
interface.

Surely it has been requested and discussed before... browsing the issues on
github... am I seeing it right?  It's not been posted as a new feature
request? Wonder if I should open a new thread on it...

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

Parkinbot wrote > Having followed this thread now for a while, I can see that obviously many > of us are trying to merge stuff implemented in several languages with > OpenSCAD and vice versa. One might call it loony stuff, but isn't a > programming language meant for being able to do loony stuff, without being > loony itself? > ... > Loony stuff, especially when you think about using it n-dimensional for > other shapes like airfoils, gears and so on. But isn't it, what > programmers want to do and why programmers are programmers and not users? Well not un-deliberately, my wording loony was a bit vague. I love the NACA you created and Joukowski (that's how my fluid mech book spells it) airfoil Trygon created. My point about loony isn't about amazing and beautiful things that the users created (or better: may create) but too often some users have some vague idea and expect OTHER people to do the hard work for them. In general conformal mapping is a powerful branch of math that make some very useful shapes. Especially you and Trygon's code showed the existing OpenSCAD commands are powerful enough if only more people put some hard work into it. I'd invite you to put some of your code into a library that I'm advocating. Now yes... you have been convincing there are room to expand some sort of distortion, transformation or something in OpenSCAD (like I hinted at, I've been frustrated with it myself). But I'm not sure you have been convincing enough that the core team should take on this task as priority, soon. OpenSCAD is open source, there's an open invitation on the main website to add new features. This "debate" would be a lot more substantial if someone create a new transformation and make a pitch that it should be included into the main branch. After seeing some substantive response to the "loony" challenge... I was thinking how to enable some of the "loony" ideas to progress without unwanted side-effects. The answer seems obvious, create a plug-in interface. Surely it has been requested and discussed before... browsing the issues on github... am I seeing it right? It's not been posted as a new feature request? Wonder if I should open a new thread on it... -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14611.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
ctchin
Wed, Nov 18, 2015 4:36 AM

Parkinbot wrote

a hard job implementing multidimensional cubic spline functionality in
OpenSCAD, which you get in Matlab with three lines, using cscvn() or with
five lines using 2D cubic splines.

Totally beside the point: two months ago I challenged my grad student to
create a parametric model of a branching blood vessel on the 3D printer.
There's no progress so I pretty much forgot about it.

But your response to my "loony" charge gave me some crucial hints, I think I
can figure out the break-thru and the student can do the rest.  Hopefully I
will hold a model in my hands by Monday.

Thanks!

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

Parkinbot wrote > a hard job implementing multidimensional cubic spline functionality in > OpenSCAD, which you get in Matlab with three lines, using cscvn() or with > five lines using 2D cubic splines. Totally beside the point: two months ago I challenged my grad student to create a parametric model of a branching blood vessel on the 3D printer. There's no progress so I pretty much forgot about it. But your response to my "loony" charge gave me some crucial hints, I think I can figure out the break-thru and the student can do the rest. Hopefully I will hold a model in my hands by Monday. Thanks! -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14612.html Sent from the OpenSCAD mailing list archive at Nabble.com.
T
Trygon
Wed, Nov 18, 2015 8:58 AM

The dark art of non affine transformations part II - Art (?) :

// this does not actually work, there is no transform() command at present!
transform()=let(sf1=1+sin(12atan2(y,x))/8, sf2=2+cos(z1.1+70))
[xsf1sf2, ysf1sf2, z] cylinder(h=300, r=50, center=true, $fn=240);

-Trygon

http://forum.openscad.org/file/n14615/TransformArt.png

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

The dark art of non affine transformations part II - Art (?) : // this does not actually work, there is no transform() command at present! transform()=let(sf1=1+sin(12*atan2(y,x))/8, sf2=2+cos(z*1.1+70)) [x*sf1*sf2, y*sf1*sf2, z] cylinder(h=300, r=50, center=true, $fn=240); -Trygon <http://forum.openscad.org/file/n14615/TransformArt.png> -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14615.html Sent from the OpenSCAD mailing list archive at Nabble.com.
T
Trygon
Wed, Nov 18, 2015 9:28 AM

The same non affine transformation applied to a different solid:

// this does not actually work, there is no transform() command at present!
transform()=let(sf1=1+sin(12atan2(y,x))/8, sf2=2+cos(z1.1+70))
[xsf1sf2, ysf1sf2, z] cube(size=[100, 100, 300], center=true);

http://forum.openscad.org/file/n14616/TransformArt2.png

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

The same non affine transformation applied to a different solid: // this does not actually work, there is no transform() command at present! transform()=let(sf1=1+sin(12*atan2(y,x))/8, sf2=2+cos(z*1.1+70)) [x*sf1*sf2, y*sf1*sf2, z] cube(size=[100, 100, 300], center=true); <http://forum.openscad.org/file/n14616/TransformArt2.png> -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14616.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
ctchin
Wed, Nov 18, 2015 12:17 PM

You could also do  some nice things without non-affine transformation.

Thanks to the warm discussion, I spent my day (not quite 7 hours of coding)
making the blood vessel I wanted 2 months ago.  Sometimes all it take is
some determination.

~80 lines of code (with comments) gave me what I needed, without even
resorting to Matlab.

Pushing 200 lines of code if I kept all the debugging/evolving codes in
place.  Note that the pipe diameter changes along the pipe length, the wall
thickness is very nearly uniform.

Plus now I have a new library for making cylinders and pipes along an
arbitrary (but not too crazy) curve.

http://forum.openscad.org/file/n14618/bifurcation.jpg
http://forum.openscad.org/file/n14618/bifurcation-cutaway.jpg

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

You could also do some nice things without non-affine transformation. Thanks to the warm discussion, I spent my day (not quite 7 hours of coding) making the blood vessel I wanted 2 months ago. Sometimes all it take is some determination. ~80 lines of code (with comments) gave me what I needed, without even resorting to Matlab. Pushing 200 lines of code if I kept all the debugging/evolving codes in place. Note that the pipe diameter changes along the pipe length, the wall thickness is very nearly uniform. Plus now I have a new library for making cylinders and pipes along an arbitrary (but not too crazy) curve. <http://forum.openscad.org/file/n14618/bifurcation.jpg> <http://forum.openscad.org/file/n14618/bifurcation-cutaway.jpg> -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14618.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DM
doug moen
Wed, Nov 18, 2015 2:13 PM

The proposed tranform() module is awesome, no doubt.

If this gets implemented before OpenSCAD2, then I would like the syntax to
be forward compatible with OpenSCAD2. Like this:

transform(
f(x,y,z)=
let (sf1=1+sin(12atan2(y,x))/8, sf2=2+cos(z1.1+70))
[xsf1sf2, ysf1sf2, z] )
cube(size=[100, 100, 300], center=true);

On 18 November 2015 at 04:28, Trygon db5765@outlook.com wrote:

The same non affine transformation applied to a different solid:

// this does not actually work, there is no transform() command at present!
transform()=let(sf1=1+sin(12atan2(y,x))/8, sf2=2+cos(z1.1+70))
[xsf1sf2, ysf1sf2, z] cube(size=[100, 100, 300], center=true);

http://forum.openscad.org/file/n14616/TransformArt2.png

--
View this message in context:
http://forum.openscad.org/Non-Linear-Transformations-tp14539p14616.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

The proposed tranform() module is awesome, no doubt. If this gets implemented before OpenSCAD2, then I would like the syntax to be forward compatible with OpenSCAD2. Like this: transform( f(x,y,z)= let (sf1=1+sin(12*atan2(y,x))/8, sf2=2+cos(z*1.1+70)) [x*sf1*sf2, y*sf1*sf2, z] ) cube(size=[100, 100, 300], center=true); On 18 November 2015 at 04:28, Trygon <db5765@outlook.com> wrote: > The same non affine transformation applied to a different solid: > > // this does not actually work, there is no transform() command at present! > transform()=let(sf1=1+sin(12*atan2(y,x))/8, sf2=2+cos(z*1.1+70)) > [x*sf1*sf2, y*sf1*sf2, z] cube(size=[100, 100, 300], center=true); > > <http://forum.openscad.org/file/n14616/TransformArt2.png> > > > > -- > View this message in context: > http://forum.openscad.org/Non-Linear-Transformations-tp14539p14616.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 > > >
R
runsun
Wed, Nov 18, 2015 2:47 PM

ctchin wrote

~80 lines of code (with comments) gave me what I needed, without even
resorting to Matlab.

Pushing 200 lines of code if I kept all the debugging/evolving codes in
place.  Note that the pipe diameter changes along the pipe length, the
wall thickness is very nearly uniform.

Plus now I have a new library for making cylinders and pipes along an
arbitrary (but not too crazy) curve.

Can you share how you join the two tubes? partial code would be even better.


$  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-tp14539p14620.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

ctchin wrote > ~80 lines of code (with comments) gave me what I needed, without even > resorting to Matlab. > > Pushing 200 lines of code if I kept all the debugging/evolving codes in > place. Note that the pipe diameter changes along the pipe length, the > wall thickness is very nearly uniform. > > Plus now I have a new library for making cylinders and pipes along an > arbitrary (but not too crazy) curve. Can you share how you join the two tubes? partial code would be even better. ----- $ 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-tp14539p14620.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Wed, Nov 18, 2015 4:02 PM

Trygon,

We’ve been compiling some demos of what can be done in user space by manually managing vertices:
https://github.com/openscad/list-comprehension-demos

This is more of a playground to explore what sort of functionality should be built into OpenSCAD.

For these demos, we currently only use 2D object as basis, see https://github.com/openscad/scad-utils/blob/master/shapes.scad

It would be cool to add some of your experiments to this repository, for purpose of creating a join exploratory playground until we land on a good interface for this kind of functionality.

Cheers,

-Marius

Trygon, We’ve been compiling some demos of what can be done in user space by manually managing vertices: https://github.com/openscad/list-comprehension-demos This is more of a playground to explore what sort of functionality should be built into OpenSCAD. For these demos, we currently only use 2D object as basis, see https://github.com/openscad/scad-utils/blob/master/shapes.scad It would be cool to add some of your experiments to this repository, for purpose of creating a join exploratory playground until we land on a good interface for this kind of functionality. Cheers, -Marius
C
ctchin
Wed, Nov 18, 2015 7:03 PM

Heheh, I guess you have asked for the crucial trick.  The question is how to
join two cylinders at an angle with a satisfactory "elbow".  Once you
figured that, the rest is just putting the Lego pieces together to make
cylinders and pipes along any paths.  Branching also becomes obvious.

The following code is robust, except for one factor: h=2*d0, the factor 2 is
arbitrary and will fail if angle is too small.  It's easy enough to fix, but
I've decided to finish working on my branching vessels rather than fix a
problem that only happens with unnatural-looking kinks.

The color("red") is obviously unnecessary, it's just to show the important
"elbow".

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

Heheh, I guess you have asked for the crucial trick. The question is how to join two cylinders at an angle with a satisfactory "elbow". Once you figured that, the rest is just putting the Lego pieces together to make cylinders and pipes along any paths. Branching also becomes obvious. The following code is robust, except for one factor: h=2*d0, the factor 2 is arbitrary and will fail if angle is too small. It's easy enough to fix, but I've decided to finish working on my branching vessels rather than fix a problem that only happens with unnatural-looking kinks. The color("red") is obviously unnecessary, it's just to show the important "elbow". -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14626.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Wed, Nov 18, 2015 8:55 PM

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

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

If I was a pipe I'd prefer to be modelled like this (works for any angle ): -- View this message in context: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14627.html Sent from the OpenSCAD mailing list archive at Nabble.com.