# restrict hull function to one or two dimensions

42 messages
123
Open this post in threaded view
|

## restrict hull function to one or two dimensions

 This post has NOT been accepted by the mailing list yet. I am trying to modulate an object by not changing it's suface so I designed a code for it to be sliced and the slices be rearranged after a custom equation. The problem I have is that if the object is not flat and has holes that need to be preserved, hull does not help much. As a test, we place two objects and use the code, the two join. Of course, in a simplified case, I can cut the object and create a module out of every cut, but is there a way to automize this for, let's say, 100 modules?   module test() { cube([200,10,2]); translate([0,12,0]) cube([200,10,2]); } //variables for cut points ca1=-8.89; ca2=-8.9; cb1=-9.89; cb2=-9.9; //variables for equation a=110; b=125; c=-250; //variables for y cut points yca1=-8.89; yca2=-8.9; ycb1=-9.89; ycb2=-9.9; //variables for y equation ya=110; yb=125; yc=-250; module x2() { for (z = [1:50]) hull() { translate([0,0,log(z+a)*b+c]) { difference() { test(); translate([z+ca1,-10,-1]) cube([300,200,200]);   translate([ca2-300+z,-100,-1]) cube([300,200,200]); } } translate([0,0,log(z+a-1)*b+c]) { difference() { test(); translate([z+cb1,-10,-1]) cube([300,200,200]);   translate([-300+cb2+z,-100,-1]) cube([300,200,200]); } } } } x2();
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 Administrator rav0r wrote I am trying to modulate an object by not changing it's suface so I designed a code for it to be sliced and the slices be rearranged after a custom equation. The problem I have is that if the object is not flat and has holes that need to be preserved, hull does not help much. As a test, we place two objects and use the code, the two join. Of course, in a simplified case, I can cut the object and create a module out of every cut, but is there a way to automize this for, let's say, 100 modules?   module test() { cube([200,10,2]); translate([0,12,0]) cube([200,10,2]); } //variables for cut points ca1=-8.89; ca2=-8.9; cb1=-9.89; cb2=-9.9; //variables for equation a=110; b=125; c=-250; //variables for y cut points yca1=-8.89; yca2=-8.9; ycb1=-9.89; ycb2=-9.9; //variables for y equation ya=110; yb=125; yc=-250; module x2() { for (z = [1:50]) hull() { translate([0,0,log(z+a)*b+c]) { difference() { test(); translate([z+ca1,-10,-1]) cube([300,200,200]);   translate([ca2-300+z,-100,-1]) cube([300,200,200]); } } translate([0,0,log(z+a-1)*b+c]) { difference() { test(); translate([z+cb1,-10,-1]) cube([300,200,200]);   translate([-300+cb2+z,-100,-1]) cube([300,200,200]); } } } } x2(); bump, as it didn't make it to the mailing list. Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 On 2016-03-25 02:41, MichaelAtOz wrote: > rav0r wrote >> I am trying to modulate an object by not changing it's suface so I >> designed a code for it to be sliced and the slices be rearranged after >> a >> custom equation. The problem I have is that if the object is not flat >> and >> has holes that need to be preserved, hull does not help much. As a >> test, >> we place two objects and use the code, the two join. Of course, in a >> simplified case, I can cut the object and create a module out of every >> cut, but is there a way to automize this for, let's say, 100 modules? You could perhaps slice the model by means of many intersection()'s with a thin+wide cube(), stacked on top of each other. This could be in z,y,z or some other direction. Then reassemble by modulating the slices as preferred and scale up the slice thickness slightly. Finally union() the modulated slices. This should preserve holes and surface shapes. Not sure if it will work in practice, but you could try. Carsten Arnholm _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 In reply to this post by MichaelAtOz Do you mean something like that: module test2() {   translate([100,0,0])   difference(){     cylinder(r=100,h=10,center=true);     cylinder(r=50,h=12,center=true);   } }  module slice(x,d) {    intersection(){      children();      translate([x,0,0])        cube([d,1000,1000],center=true);    }  }    function shear_transf(x1,x2,d) = let( r=d/(x2-x1) )     [ [1,0,0,0], [0,1,0,0], [r,0,1,-r*x1], [0,0,0,1] ];    module shear(x1,x2,d) {    multmatrix(shear_transf(x1,x2,d)) children();  }    function f(x,a,b,c) = a*x*x+b*x+c;    module modulate(a,b,c,x1,x2,d){    for(x=[x1:d:x2]) {      translate([0,0,f(x,a,b,c)])        shear(x,x+d,f(x+d,a,b,c)-f(x,a,b,c)) slice(x,d) children();    }  }   modulate(-0.01, 1.5, 10, 0, 200, 2) test2(); translate([0,0,-200]) test2();
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 I love it! Jon On 3/25/2016 9:38 AM, Ronaldo wrote: > module test2() { >    translate([100,0,0]) >    difference(){ >      cylinder(r=100,h=10,center=true); >      cylinder(r=50,h=12,center=true); >    } > } > >   module slice(x,d) { >     intersection(){ >       children(); >       translate([x,0,0]) >         cube([d,1000,1000],center=true); >     } >   } >   >   function shear_transf(x1,x2,d) = let( r=d/(x2-x1) ) >      [ [1,0,0,0], [0,1,0,0], [r,0,1,-r*x1], [0,0,0,1] ]; >   >   module shear(x1,x2,d) { >     multmatrix(shear_transf(x1,x2,d)) children(); >   } >   >   function f(x,a,b,c) = a*x*x+b*x+c; >   >   module modulate(a,b,c,x1,x2,d){ >     for(x=[x1:d:x2]) { >       translate([0,0,f(x,a,b,c)]) >         shear(x,x+d,f(x+d,a,b,c)-f(x,a,b,c)) slice(x,d) children(); >     } >   } >   > modulate(-0.01, 1.5, 10, 0, 200, 2) test2(); > translate([0,0,-200]) test2(); > _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 In reply to this post by Ronaldo @ Ronaldo: Very good example usage of multmatrix. Thx for sharing. \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 In reply to this post by Ronaldo There was a mistake in the definition of module modulate. The correct one would be:  module modulate(a,b,c,x1,x2,dx){    for(x=[x1:dx:x2]) {      translate([0,0,f(x+dx/2,a,b,c)])        shear(x,x+dx,f(x+dx,a,b,c)-f(x,a,b,c)) slice(x,dx) children();    }  }
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 This post was updated on . In reply to this post by cacb It did work, I came up with this idea, but it takes days to render. Will try out Ronaldo's version.
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 It's a frame with a grid, about 250mm long, 80 mm wide and 5 bars (longtitudinal) plus 3 cross bars. Openscad is the only application that can work without issues in regard to "full" stl's, not only facets.
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 I would take a very different approach for your problem. I would "modulate" the center lines of each bar, sweep each with the bar section and union everything. A sweep module may be found in: https://github.com/openscad/list-comprehension-demosTake the sweep-path.scad as an example. And ask for help if you need.
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 In reply to this post by Ronaldo That is easier said than done, but the frame has an irregular shape. I could, of course use this module http://www.thingiverse.com/thing:210099 for the extrusion but I need all the grid's elements to have a specific bevel and 3D orientation. I guess the whole job is harder than I thought, though, for a core 2 duo cpu. Probably an i7 would do just fine.
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 Do you have an image of the frame?2016-04-06 14:08 GMT-03:00 rav0r :That is easier said than done, but the frame has an irregular shape. I could, of course use this module http://www.thingiverse.com/thing:210099 for the extrusion but I need all the grid's elements to have a specific bevel and 3D orientation. I guess the whole job is harder than I thought, though, for a core 2 duo cpu. Probably an i7 would do just fine. -- View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16987.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ 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
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 Rendering Polygon Mesh using CGAL... WARNING: CGAL Evaluator: Root node didn't fit into cache PolySets in cache: 9 PolySet cache size in bytes: 221448 CGAL Polyhedrons in cache: 597 CGAL cache size in bytes: 104854928    Top level object is a 3D object:    Simple:        yes    Vertices:   175957    Halfedges:  529502    Edges:      264751    Halffacets: 191240    Facets:      95620    Volumes:      3420 Total rendering time: 20 hours, 48 minutes, 39 seconds Rendering finished. In reality, it took 3 times that much as it says.
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 //bevel use module grila() { union() { //grid translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_pct.dxf"); } //horizontal translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_1.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_2.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_3.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_4.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_5.dxf"); } //vertical translate ([0,0,0]){ linear_extrude(height=3) import("rama_vert.dxf"); } } } grila();
Open this post in threaded view
|

## Re: restrict hull function to one or two dimensions

 I can't reproduce your model without the dxf files.Do you have images of your them?2016-04-09 18:38 GMT-03:00 rav0r ://bevel use module grila() { union() { //grid translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_pct.dxf"); } //horizontal translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_1.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_2.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_3.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_4.dxf"); } translate ([0,0,0]){ bevel_extrude(height=10,bevel_depth=6,\$fn=16)import("rama_oriz_5.dxf"); } //vertical translate ([0,0,0]){ linear_extrude(height=3) import("rama_vert.dxf"); } } } grila(); -- View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p17014.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ 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