discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

how to fill an arbitrary 2D shape with honeycomb pattern?

DP
Dan Perry
Fri, Feb 3, 2023 3:12 AM

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range of
coordinates.  Suggestions are welcome😊)
Thanks,
Dan

I would like to fill an arbitrary convex shape with hexagons (honeycomb pattern). I wrote a couple modules that do this on a circle and donut, but an arbitrary shape is more challenging, primarily because I haven't found a straightforward way to calculate the left/right/top/bottom extremes of an arbitrary 2D shape, so I know where to start and stop. (I'm planning to use BOSL2 point_in_region() once I figure out the range of coordinates. Suggestions are welcome😊) Thanks, Dan
AM
Adrian Mariano
Fri, Feb 3, 2023 3:16 AM

If you're planning to use point_in_region() that implies that you have your
shape described by a point list, which means you can just run max() on the
columns, or use BOSL2 pointlist_bounds() to do it for you.

On Thu, Feb 2, 2023 at 10:13 PM Dan Perry dan.p3rry@gmail.com wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range
of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

If you're planning to use point_in_region() that implies that you have your shape described by a point list, which means you can just run max() on the columns, or use BOSL2 pointlist_bounds() to do it for you. On Thu, Feb 2, 2023 at 10:13 PM Dan Perry <dan.p3rry@gmail.com> wrote: > I would like to fill an arbitrary convex shape with hexagons (honeycomb > pattern). > I wrote a couple modules that do this on a circle and donut, but an > arbitrary shape is more challenging, primarily because I haven't found a > straightforward way to calculate the left/right/top/bottom extremes of an > arbitrary 2D shape, so I know where to start and stop. > (I'm planning to use BOSL2 point_in_region() once I figure out the range > of coordinates. Suggestions are welcome😊) > Thanks, > Dan > > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Fri, Feb 3, 2023 3:33 AM

How about building a honeycomb that is larger than your object, and then
intersecting it with your object?

How about building a honeycomb that is larger than your object, and then intersecting it with your object?
DP
Dan Perry
Fri, Feb 3, 2023 5:10 AM

Hi Adrian,
Thanks for your tips, they helped a lot.  Once I re-read the documentation
and figured out that point_in_region() returns 1, 0, or -1, not 0 and 1, I
got the code to work,
Dan

On Thu, Feb 2, 2023 at 7:17 PM Adrian Mariano avm4@cornell.edu wrote:

If you're planning to use point_in_region() that implies that you have
your shape described by a point list, which means you can just run max() on
the columns, or use BOSL2 pointlist_bounds() to do it for you.

On Thu, Feb 2, 2023 at 10:13 PM Dan Perry dan.p3rry@gmail.com wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range
of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Hi Adrian, Thanks for your tips, they helped a lot. Once I re-read the documentation and figured out that point_in_region() returns 1, 0, or -1, not 0 and 1, I got the code to work, Dan On Thu, Feb 2, 2023 at 7:17 PM Adrian Mariano <avm4@cornell.edu> wrote: > If you're planning to use point_in_region() that implies that you have > your shape described by a point list, which means you can just run max() on > the columns, or use BOSL2 pointlist_bounds() to do it for you. > > > On Thu, Feb 2, 2023 at 10:13 PM Dan Perry <dan.p3rry@gmail.com> wrote: > >> I would like to fill an arbitrary convex shape with hexagons (honeycomb >> pattern). >> I wrote a couple modules that do this on a circle and donut, but an >> arbitrary shape is more challenging, primarily because I haven't found a >> straightforward way to calculate the left/right/top/bottom extremes of an >> arbitrary 2D shape, so I know where to start and stop. >> (I'm planning to use BOSL2 point_in_region() once I figure out the range >> of coordinates. Suggestions are welcome😊) >> Thanks, >> Dan >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Fri, Feb 3, 2023 5:14 PM

I just wrote the function honeycomb and function to get the segments inside
any arbitrary enclosed section.
It is defined in such a way that only the segments which are completely
within the section are selected
[image: Screenshot 2023-02-03 at 10.37.14 PM.png]

On Fri, 3 Feb 2023 at 08:44, Dan Perry dan.p3rry@gmail.com wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range
of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I just wrote the function honeycomb and function to get the segments inside any arbitrary enclosed section. It is defined in such a way that only the segments which are completely within the section are selected [image: Screenshot 2023-02-03 at 10.37.14 PM.png] On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com> wrote: > I would like to fill an arbitrary convex shape with hexagons (honeycomb > pattern). > I wrote a couple modules that do this on a circle and donut, but an > arbitrary shape is more challenging, primarily because I haven't found a > straightforward way to calculate the left/right/top/bottom extremes of an > arbitrary 2D shape, so I know where to start and stop. > (I'm planning to use BOSL2 point_in_region() once I figure out the range > of coordinates. Suggestions are welcome😊) > Thanks, > Dan > > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
DP
Dan Perry
Fri, Feb 3, 2023 5:59 PM

Very cool, are you going to share?

On Fri, Feb 3, 2023 at 9:15 AM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I just wrote the function honeycomb and function to get the segments
inside any arbitrary enclosed section.
It is defined in such a way that only the segments which are completely
within the section are selected
[image: Screenshot 2023-02-03 at 10.37.14 PM.png]

On Fri, 3 Feb 2023 at 08:44, Dan Perry dan.p3rry@gmail.com wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range
of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Very cool, are you going to share? On Fri, Feb 3, 2023 at 9:15 AM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > I just wrote the function honeycomb and function to get the segments > inside any arbitrary enclosed section. > It is defined in such a way that only the segments which are completely > within the section are selected > [image: Screenshot 2023-02-03 at 10.37.14 PM.png] > > > On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com> wrote: > >> I would like to fill an arbitrary convex shape with hexagons (honeycomb >> pattern). >> I wrote a couple modules that do this on a circle and donut, but an >> arbitrary shape is more challenging, primarily because I haven't found a >> straightforward way to calculate the left/right/top/bottom extremes of an >> arbitrary 2D shape, so I know where to start and stop. >> (I'm planning to use BOSL2 point_in_region() once I figure out the range >> of coordinates. Suggestions are welcome😊) >> Thanks, >> Dan >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RD
Revar Desmera
Fri, Feb 3, 2023 7:51 PM

Using BOSL2, a lot of the work can be done for you:

include <BOSL2/std.scad>
honeycomb(shape) =
let(
hex = hexagon(d=5, spin=180/6),
bounds = pointlist_bounds(shape),
size = bounds[1] - bounds[0],
hex_rgn2 = grid_copies(spacing=5, size=size, stagger=true, p=hex),
center = (bounds[0] + bounds[1]) / 2,
hex_rgn = move(center, p=hex_rgn2),
ihex_rgn = intersection(hex_rgn, shape),
out_rgn = difference(shape, ihex_rgn)
) out_rgn;

module honeycomb(shape) {
rgn = honeycomb(shape);
region(rgn);
}

shape = star(n=5, step=2, d=100, spin=90/5);
%region(shape);
color("blue") honeycomb(shape);



  • Revar

On Feb 3, 2023, at 9:14 AM, Sanjeev Prabhakar sprabhakar2006@gmail.com wrote:

I just wrote the function honeycomb and function to get the segments inside any arbitrary enclosed section.
It is defined in such a way that only the segments which are completely within the section are selected
<Screenshot 2023-02-03 at 10.37.14 PM.png>

On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com mailto:dan.p3rry@gmail.com> wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb pattern).
I wrote a couple modules that do this on a circle and donut, but an arbitrary shape is more challenging, primarily because I haven't found a straightforward way to calculate the left/right/top/bottom extremes of an arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Using BOSL2, a lot of the work can be done for you: include <BOSL2/std.scad> honeycomb(shape) = let( hex = hexagon(d=5, spin=180/6), bounds = pointlist_bounds(shape), size = bounds[1] - bounds[0], hex_rgn2 = grid_copies(spacing=5, size=size, stagger=true, p=hex), center = (bounds[0] + bounds[1]) / 2, hex_rgn = move(center, p=hex_rgn2), ihex_rgn = intersection(hex_rgn, shape), out_rgn = difference(shape, ihex_rgn) ) out_rgn; module honeycomb(shape) { rgn = honeycomb(shape); region(rgn); } shape = star(n=5, step=2, d=100, spin=90/5); %region(shape); color("blue") honeycomb(shape);  - Revar > On Feb 3, 2023, at 9:14 AM, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > > I just wrote the function honeycomb and function to get the segments inside any arbitrary enclosed section. > It is defined in such a way that only the segments which are completely within the section are selected > <Screenshot 2023-02-03 at 10.37.14 PM.png> > > > On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com <mailto:dan.p3rry@gmail.com>> wrote: >> I would like to fill an arbitrary convex shape with hexagons (honeycomb pattern). >> I wrote a couple modules that do this on a circle and donut, but an arbitrary shape is more challenging, primarily because I haven't found a straightforward way to calculate the left/right/top/bottom extremes of an arbitrary 2D shape, so I know where to start and stop. >> (I'm planning to use BOSL2 point_in_region() once I figure out the range of coordinates. Suggestions are welcome😊) >> Thanks, >> Dan >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RD
Revar Desmera
Fri, Feb 3, 2023 7:59 PM

I forgot to add parameters for hex size and cell wall thickness.  Here's updated code:

function honeycomb(shape, spacing=10, hex_wall=1) =
let(
hex = hexagon(od=spacing-hex_wall/2, spin=180/6),
bounds = pointlist_bounds(shape),
size = bounds[1] - bounds[0],
hex_rgn2 = grid_copies(spacing=spacing, size=size, stagger=true, p=hex),
center = (bounds[0] + bounds[1]) / 2,
hex_rgn = move(center, p=hex_rgn2),
ihex_rgn = intersection(hex_rgn, shape),
out_rgn = difference(shape, ihex_rgn)
) out_rgn;

module honeycomb(shape, spacing=10, hex_wall=1) {
rgn = honeycomb(shape, spacing=spacing, hex_wall=hex_wall);
region(rgn);
}

shape = star(n=5, step=2, d=100, spin=90/5);
%region(shape);
color("blue") honeycomb(shape, spacing=8, hex_wall=0.8);

  • Revar

On Feb 3, 2023, at 11:51 AM, Revar Desmera revarbat@gmail.com wrote:

Using BOSL2, a lot of the work can be done for you:

include <BOSL2/std.scad>
honeycomb(shape) =
let(
hex = hexagon(d=5, spin=180/6),
bounds = pointlist_bounds(shape),
size = bounds[1] - bounds[0],
hex_rgn2 = grid_copies(spacing=5, size=size, stagger=true, p=hex),
center = (bounds[0] + bounds[1]) / 2,
hex_rgn = move(center, p=hex_rgn2),
ihex_rgn = intersection(hex_rgn, shape),
out_rgn = difference(shape, ihex_rgn)
) out_rgn;

module honeycomb(shape) {
rgn = honeycomb(shape);
region(rgn);
}

shape = star(n=5, step=2, d=100, spin=90/5);
%region(shape);
color("blue") honeycomb(shape);

<Screenshot 2023-02-03 at 11.49.17 AM.png>

  • Revar

On Feb 3, 2023, at 9:14 AM, Sanjeev Prabhakar sprabhakar2006@gmail.com wrote:

I just wrote the function honeycomb and function to get the segments inside any arbitrary enclosed section.
It is defined in such a way that only the segments which are completely within the section are selected
<Screenshot 2023-02-03 at 10.37.14 PM.png>

On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com mailto:dan.p3rry@gmail.com> wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb pattern).
I wrote a couple modules that do this on a circle and donut, but an arbitrary shape is more challenging, primarily because I haven't found a straightforward way to calculate the left/right/top/bottom extremes of an arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I forgot to add parameters for hex size and cell wall thickness. Here's updated code: function honeycomb(shape, spacing=10, hex_wall=1) = let( hex = hexagon(od=spacing-hex_wall/2, spin=180/6), bounds = pointlist_bounds(shape), size = bounds[1] - bounds[0], hex_rgn2 = grid_copies(spacing=spacing, size=size, stagger=true, p=hex), center = (bounds[0] + bounds[1]) / 2, hex_rgn = move(center, p=hex_rgn2), ihex_rgn = intersection(hex_rgn, shape), out_rgn = difference(shape, ihex_rgn) ) out_rgn; module honeycomb(shape, spacing=10, hex_wall=1) { rgn = honeycomb(shape, spacing=spacing, hex_wall=hex_wall); region(rgn); } shape = star(n=5, step=2, d=100, spin=90/5); %region(shape); color("blue") honeycomb(shape, spacing=8, hex_wall=0.8); - Revar > On Feb 3, 2023, at 11:51 AM, Revar Desmera <revarbat@gmail.com> wrote: > > Using BOSL2, a lot of the work can be done for you: > > include <BOSL2/std.scad> > honeycomb(shape) = > let( > hex = hexagon(d=5, spin=180/6), > bounds = pointlist_bounds(shape), > size = bounds[1] - bounds[0], > hex_rgn2 = grid_copies(spacing=5, size=size, stagger=true, p=hex), > center = (bounds[0] + bounds[1]) / 2, > hex_rgn = move(center, p=hex_rgn2), > ihex_rgn = intersection(hex_rgn, shape), > out_rgn = difference(shape, ihex_rgn) > ) out_rgn; > > module honeycomb(shape) { > rgn = honeycomb(shape); > region(rgn); > } > > shape = star(n=5, step=2, d=100, spin=90/5); > %region(shape); > color("blue") honeycomb(shape); > > <Screenshot 2023-02-03 at 11.49.17 AM.png> > > - Revar > > > >> On Feb 3, 2023, at 9:14 AM, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: >> >> I just wrote the function honeycomb and function to get the segments inside any arbitrary enclosed section. >> It is defined in such a way that only the segments which are completely within the section are selected >> <Screenshot 2023-02-03 at 10.37.14 PM.png> >> >> >> On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com <mailto:dan.p3rry@gmail.com>> wrote: >>> I would like to fill an arbitrary convex shape with hexagons (honeycomb pattern). >>> I wrote a couple modules that do this on a circle and donut, but an arbitrary shape is more challenging, primarily because I haven't found a straightforward way to calculate the left/right/top/bottom extremes of an arbitrary 2D shape, so I know where to start and stop. >>> (I'm planning to use BOSL2 point_in_region() once I figure out the range of coordinates. Suggestions are welcome😊) >>> Thanks, >>> Dan >>> >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Sat, Feb 4, 2023 12:17 AM

You can see file
Example of various functions.ipynb here

https://github.com/sprabhakar2006/openSCAD/blob/main/example%20of%20various%20functions.ipynb

The last example right now is this.

Function honeycomb is written in file openscad1.py

https://github.com/sprabhakar2006/openSCAD/blob/main/openscad1.py

On Fri, 3 Feb, 2023, 11:30 pm Dan Perry, dan.p3rry@gmail.com wrote:

Very cool, are you going to share?

On Fri, Feb 3, 2023 at 9:15 AM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I just wrote the function honeycomb and function to get the segments
inside any arbitrary enclosed section.
It is defined in such a way that only the segments which are completely
within the section are selected
[image: Screenshot 2023-02-03 at 10.37.14 PM.png]

On Fri, 3 Feb 2023 at 08:44, Dan Perry dan.p3rry@gmail.com wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range
of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

You can see file Example of various functions.ipynb here https://github.com/sprabhakar2006/openSCAD/blob/main/example%20of%20various%20functions.ipynb The last example right now is this. Function honeycomb is written in file openscad1.py https://github.com/sprabhakar2006/openSCAD/blob/main/openscad1.py On Fri, 3 Feb, 2023, 11:30 pm Dan Perry, <dan.p3rry@gmail.com> wrote: > Very cool, are you going to share? > > > On Fri, Feb 3, 2023 at 9:15 AM Sanjeev Prabhakar <sprabhakar2006@gmail.com> > wrote: > >> I just wrote the function honeycomb and function to get the segments >> inside any arbitrary enclosed section. >> It is defined in such a way that only the segments which are completely >> within the section are selected >> [image: Screenshot 2023-02-03 at 10.37.14 PM.png] >> >> >> On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com> wrote: >> >>> I would like to fill an arbitrary convex shape with hexagons (honeycomb >>> pattern). >>> I wrote a couple modules that do this on a circle and donut, but an >>> arbitrary shape is more challenging, primarily because I haven't found a >>> straightforward way to calculate the left/right/top/bottom extremes of an >>> arbitrary 2D shape, so I know where to start and stop. >>> (I'm planning to use BOSL2 point_in_region() once I figure out the range >>> of coordinates. Suggestions are welcome😊) >>> Thanks, >>> Dan >>> >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Sat, Feb 4, 2023 12:24 AM

If you see it carefully in the example shared by me it is not intersection.

In example shared by you it is intersection which is easier.

The intent of Dan seems to be to get the complete honeycomb inside a shape

On Sat, 4 Feb, 2023, 1:22 am Revar Desmera, revarbat@gmail.com wrote:

Using BOSL2, a lot of the work can be done for you:

include <BOSL2/std.scad>
honeycomb(shape) =
let(
hex = hexagon(d=5, spin=180/6),
bounds = pointlist_bounds(shape),
size = bounds[1] - bounds[0],
hex_rgn2 = grid_copies(spacing=5, size=size, stagger=true, p=hex),
center = (bounds[0] + bounds[1]) / 2,
hex_rgn = move(center, p=hex_rgn2),
ihex_rgn = intersection(hex_rgn, shape),
out_rgn = difference(shape, ihex_rgn)
) out_rgn;

module honeycomb(shape) {
rgn = honeycomb(shape);
region(rgn);
}

shape = star(n=5, step=2, d=100, spin=90/5);
%region(shape);
color("blue") honeycomb(shape);

[image: Screenshot 2023-02-03 at 11.49.17 AM.png]

  • Revar

On Feb 3, 2023, at 9:14 AM, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

I just wrote the function honeycomb and function to get the segments
inside any arbitrary enclosed section.
It is defined in such a way that only the segments which are completely
within the section are selected
<Screenshot 2023-02-03 at 10.37.14 PM.png>

On Fri, 3 Feb 2023 at 08:44, Dan Perry dan.p3rry@gmail.com wrote:

I would like to fill an arbitrary convex shape with hexagons (honeycomb
pattern).
I wrote a couple modules that do this on a circle and donut, but an
arbitrary shape is more challenging, primarily because I haven't found a
straightforward way to calculate the left/right/top/bottom extremes of an
arbitrary 2D shape, so I know where to start and stop.
(I'm planning to use BOSL2 point_in_region() once I figure out the range
of coordinates.  Suggestions are welcome😊)
Thanks,
Dan


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

If you see it carefully in the example shared by me it is not intersection. In example shared by you it is intersection which is easier. The intent of Dan seems to be to get the complete honeycomb inside a shape On Sat, 4 Feb, 2023, 1:22 am Revar Desmera, <revarbat@gmail.com> wrote: > Using BOSL2, a lot of the work can be done for you: > > include <BOSL2/std.scad> > honeycomb(shape) = > let( > hex = hexagon(d=5, spin=180/6), > bounds = pointlist_bounds(shape), > size = bounds[1] - bounds[0], > hex_rgn2 = grid_copies(spacing=5, size=size, stagger=true, p=hex), > center = (bounds[0] + bounds[1]) / 2, > hex_rgn = move(center, p=hex_rgn2), > ihex_rgn = intersection(hex_rgn, shape), > out_rgn = difference(shape, ihex_rgn) > ) out_rgn; > > module honeycomb(shape) { > rgn = honeycomb(shape); > region(rgn); > } > > shape = star(n=5, step=2, d=100, spin=90/5); > %region(shape); > color("blue") honeycomb(shape); > > > [image: Screenshot 2023-02-03 at 11.49.17 AM.png] > > - Revar > > > > On Feb 3, 2023, at 9:14 AM, Sanjeev Prabhakar <sprabhakar2006@gmail.com> > wrote: > > I just wrote the function honeycomb and function to get the segments > inside any arbitrary enclosed section. > It is defined in such a way that only the segments which are completely > within the section are selected > <Screenshot 2023-02-03 at 10.37.14 PM.png> > > > On Fri, 3 Feb 2023 at 08:44, Dan Perry <dan.p3rry@gmail.com> wrote: > >> I would like to fill an arbitrary convex shape with hexagons (honeycomb >> pattern). >> I wrote a couple modules that do this on a circle and donut, but an >> arbitrary shape is more challenging, primarily because I haven't found a >> straightforward way to calculate the left/right/top/bottom extremes of an >> arbitrary 2D shape, so I know where to start and stop. >> (I'm planning to use BOSL2 point_in_region() once I figure out the range >> of coordinates. Suggestions are welcome😊) >> Thanks, >> Dan >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >