[Beginner] Honeycomb - advice needed

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

[Beginner] Honeycomb - advice needed

PrzemoF
Hi,
I'm trying to make a reliable/fast honeycomb script. It works quite OK, but
it gets very slow with bigger dimensions or smaller cell size, so I need
to find a better way. I have a lot of 3D modeling experience, but that
doesn't seem to be useful without knowing the internals of openscad.

Current method:
  - hexagonal prism created from 3 cubes, 2 of them rotated by 60 deg,
  - row of hexagonal prisms created with offset between elements,
  - array created from above rows,
  - difference between the array and cube produces honeycomb

It works fine, except some artefacts, but I hope it's just a rendering problem,
but exporting to .stl takes _ages_.
Script: http://firszt.eu/openscad/honeycomb.scad
Example rendering: http://firszt.eu/openscad/hc.png

What would be the best way to improve it?
--
Kind regards,
Przemo Firszt



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: [Beginner] Honeycomb - advice needed

nophead
Make the hexagonal prism with cylinder($fn = 6, r = ..., h = ....). That should be faster.

Or make use circle($fn = 6), subtract those in 2D from a square and linear_extrude that.


On 31 May 2013 15:56, Przemo Firszt <[hidden email]> wrote:
Hi,
I'm trying to make a reliable/fast honeycomb script. It works quite OK, but
it gets very slow with bigger dimensions or smaller cell size, so I need
to find a better way. I have a lot of 3D modeling experience, but that
doesn't seem to be useful without knowing the internals of openscad.

Current method:
  - hexagonal prism created from 3 cubes, 2 of them rotated by 60 deg,
  - row of hexagonal prisms created with offset between elements,
  - array created from above rows,
  - difference between the array and cube produces honeycomb

It works fine, except some artefacts, but I hope it's just a rendering problem,
but exporting to .stl takes _ages_.
Script: http://firszt.eu/openscad/honeycomb.scad
Example rendering: http://firszt.eu/openscad/hc.png

What would be the best way to improve it?
--
Kind regards,
Przemo Firszt



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: [Beginner] Honeycomb - advice needed

Kevin Crowley
I just wrote a hexagon module.

r is the radius of the inside circle
 x and y are the coordinates of the center of the hexagon.


module hexagon(r,x,y){

polygon(points=[[(r+x),(r*(tan(30)))+y],
                [x,(r*(2/sqrt(3)))+y],
                [-r+x,(r*(tan(30)))+y],
                [-r+x,-(r*(tan(30)))+y],
                [x,-(r*(2/sqrt(3)))+y], 
                [r+x,-(r*(tan(30)))+y]]);
         
 }
 
 hexagon(1,11,-1);
 hexagon(1,0,0);


On Fri, May 31, 2013 at 10:02 AM, nop head <[hidden email]> wrote:
Make the hexagonal prism with cylinder($fn = 6, r = ..., h = ....). That should be faster.

Or make use circle($fn = 6), subtract those in 2D from a square and linear_extrude that.


On 31 May 2013 15:56, Przemo Firszt <[hidden email]> wrote:
Hi,
I'm trying to make a reliable/fast honeycomb script. It works quite OK, but
it gets very slow with bigger dimensions or smaller cell size, so I need
to find a better way. I have a lot of 3D modeling experience, but that
doesn't seem to be useful without knowing the internals of openscad.

Current method:
  - hexagonal prism created from 3 cubes, 2 of them rotated by 60 deg,
  - row of hexagonal prisms created with offset between elements,
  - array created from above rows,
  - difference between the array and cube produces honeycomb

It works fine, except some artefacts, but I hope it's just a rendering problem,
but exporting to .stl takes _ages_.
Script: http://firszt.eu/openscad/honeycomb.scad
Example rendering: http://firszt.eu/openscad/hc.png

What would be the best way to improve it?
--
Kind regards,
Przemo Firszt



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: [Beginner] Honeycomb - advice needed

PrzemoF
In reply to this post by nophead
Dnia 2013-05-31, pią o godzinie 16:02 +0100, nop head pisze:
> Make the hexagonal prism with cylinder($fn = 6, r = ..., h = ....).
> That should be faster.

Thanks! That's ~ 6 times faster than original approach!!
>
> Or make use circle($fn = 6), subtract those in 2D from a square and
> linear_extrude that.
Seems to be as fast as cylinder with $fn=6, but there are no artefacts,
so it's the best method so far.
Thanks!
Przemo


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: [Beginner] Honeycomb - advice needed

PrzemoF
In reply to this post by Kevin Crowley
Dnia 2013-06-01, sob o godzinie 10:50 -0500, Kevin Crowley pisze:

> I just wrote a hexagon module.
>
>
> r is the radius of the inside circle
>  x and y are the coordinates of the center of the hexagon.
>
>
>
>
> module hexagon(r,x,y){
>
>
> polygon(points=[[(r+x),(r*(tan(30)))+y],
>                 [x,(r*(2/sqrt(3)))+y],
>                 [-r+x,(r*(tan(30)))+y],
>                 [-r+x,-(r*(tan(30)))+y],
>                 [x,-(r*(2/sqrt(3)))+y],
>                 [r+x,-(r*(tan(30)))+y]]);
>          
>  }
>  
>  hexagon(1,11,-1);
>  hexagon(1,0,0);
>
Thanks! I tested it with my honeycomb script and works fine. However is
a bit slower that the other proposed solutions. The final version is
~10-12 times faster that my original script.

module hc_column(length, cell_size, wall_thickness) {
        no_of_cells = floor(length / (cell_size + wall_thickness)) ;

        for (i = [0 : no_of_cells]) {
                translate([0,(i * (cell_size + wall_thickness)),0])
                         circle($fn = 6, r = cell_size * (sqrt(3)/3));
        }
}

module honeycomb (length, width, height, cell_size, wall_thickness) {
        no_of_rows = floor(1.2 * length / (cell_size +
wall_thickness)) ;

        tr_mod = cell_size + wall_thickness;
        tr_x = sqrt(3)/2 * tr_mod;
        tr_y = tr_mod / 2;
        off_x = -1 * wall_thickness / 2;
        off_y = wall_thickness / 2;
        linear_extrude(height = height, center = true, convexity = 10,
twist = 0, slices = 1)
                difference(){
                        square([length, width]);
                        for (i = [0 : no_of_rows]) {
                                translate([i * tr_x + off_x, (i % 2) *
tr_y + off_y,0])
                                        hc_column(width, cell_size,
wall_thickness);
                        }
                }
}

//honeycomb(length, width, height, cell_size, wall_thickness);
honeycomb(140, 80, 20, 5, 1);


Thanks all for help!

--
Kind regards,
Przemo Firszt


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566