Author Topic: Voronoi Table Lamp  (Read 24318 times)

Offline macbob

  • Storm Trooper
  • ***
  • Posts: 189
    • View Profile
    • Bob Mackay
Voronoi Table Lamp
« on: January 28, 2014, 03:07:29 am »
This is 5mm double-sided white oak plywood.  The lights are IKEA Inreda LEDs, which fit the holes in the base.

If I was doing this again I would probably cut out the holes as a pocket, rather than as a profile, since the centre bits went all over the place and sometimes jammed the cutter, pushing it to one side.

Bob

Offline kvom

  • CNC Jedi
  • *****
  • Posts: 1612
    • View Profile
Re: Voronoi Table Lamp
« Reply #1 on: January 28, 2014, 13:03:58 pm »
Nice job.  How much machine time to do a side?

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8988
    • View Profile
Re: Voronoi Table Lamp
« Reply #2 on: January 28, 2014, 13:07:04 pm »
HEH!  MONTHS, obviously! <G>

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline macbob

  • Storm Trooper
  • ***
  • Posts: 189
    • View Profile
    • Bob Mackay
Re: Voronoi Table Lamp
« Reply #3 on: January 28, 2014, 15:33:16 pm »
Actually, about an hour per side!  Plus quite a long time cleaning it up afterwards and finishing it with oil.  Not the sort of thing you would want to make on a commercial basis!  I'm pleased with the result though!

Cheers,

Bob

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3356
    • View Profile
Re: Voronoi Table Lamp
« Reply #4 on: January 28, 2014, 17:24:27 pm »
Definitely going to make one. As you said, the finishing part will take awhile. Thanks for sharing. ;D
My 2ยข

Win11, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, 4th Axis, Endurance Laser.

Offline coolant slinger

  • Wookie
  • ****
  • Posts: 312
    • View Profile
Re: Voronoi Table Lamp
« Reply #5 on: January 29, 2014, 00:11:23 am »
Great job. Beautiful lamp. Couldn't imagine how long it would have taken without Cambam. I would hate to manually program that.

Offline PetefromTn

  • Storm Trooper
  • ***
  • Posts: 105
    • View Profile
Re: Voronoi Table Lamp
« Reply #6 on: February 14, 2014, 17:37:19 pm »
This is 5mm double-sided white oak plywood.  The lights are IKEA Inreda LEDs, which fit the holes in the base.

If I was doing this again I would probably cut out the holes as a pocket, rather than as a profile, since the centre bits went all over the place and sometimes jammed the cutter, pushing it to one side.

Bob


Damn man that is a thing of beauty to behold.  thanks for sharing it.  My wife saw the picture and was like OOH when are ya making me one LOL... WAY TO GO MAN hehe.. Peace

Pete

Offline mikek

  • Ewok
  • *
  • Posts: 31
    • View Profile
Re: Voronoi Table Lamp
« Reply #7 on: May 23, 2014, 04:38:34 am »
Hi Bob,

After reading about voronoi in this thread I've been researching it online. I grabbed the voronoi math
addon to perl and have been experimenting a bit with it. So far, when I provide a few to several dozen
points as the 'seeds' to the voronoi algorythm it produces polygon sets that look all too regular and
rather mechanical looking. How does one produce the nice organic looking polygons that you have on
your lamp? 

I've got a plugin built to create polygons in Cambam from the output of the voronoi tool. Any interest in
in this thing?

Mike


Offline macbob

  • Storm Trooper
  • ***
  • Posts: 189
    • View Profile
    • Bob Mackay
Re: Voronoi Table Lamp
« Reply #8 on: May 23, 2014, 23:54:10 pm »
Hi Mike,

My algorithm for the cell positioning was pretty basic.  I simply generated a square grid of points and randomly added a small x or y offset to each point:

Code: [Select]
#!/opt/local/bin/perl -w

use Math::Geometry::Voronoi;
use Data::Dumper;

my $x_size = 1600;
my $y_size = 500;
my $num_points = 40;
my $wildness = 0.9;

my $interval = $x_size/$num_points;
my $rand = $interval * $wildness;

# load a set of points

my @points;

for (my $x = 0; $x < $x_size; $x += $interval)
{
    for (my $y = 0; $y < $y_size; $y += $interval)
    {
        push @points, [$x + rand ($rand), $y + rand ($rand)];
    }
}




my $geo = Math::Geometry::Voronoi->new(points => \@points);

# compute your diagram
$geo->compute;

# extract features
my $lines    = $geo->lines;
# print Dumper ($lines);
my $edges    = $geo->edges;
my $vertices = $geo->vertices;

# build polygons
my @polygons = $geo->polygons;

foreach my $p (@polygons)
{
#   print "-----------------\n";
#   print Dumper ($p);
   
    my @pts = @$p;
    shift @pts; # poly number
    print join ",",
        map {($_->[0], $_->[1])} @pts;
    print "\n";
}

For the actual table lamp, I then stretched the pattern by about 10% in the long axis, for no particular reason.

The Voronoi algorithm of course works with any set of points.  One could simply randomly pick points constrained to the intended boundary and then apply the algorithm, but then some cells would be much larger than others.  I guess that the answer comes down to one's definition of "Organic".  Real growing cells start from random locations, perhaps, and when meeting form straight boundaries, but they also have limits on how large they can grow.  A square grid with insufficient randomness can be discerned as being square, or at least, too regular.  Too much randomness is also wrong.  I wrote a program to display the results as a gif, so that I could see how I was doing.  An hexagonal grid would be not much harder.

You presumably saw my thread at http://www.cambam.co.uk/forum/index.php?topic=3279.msg21020#msg21020 that has a bunch of notes on Perl experiments.

As to plugins, I'm afraid that as a Perl programmer I have no experience of them.  I think it would be wonderful to have a plugin where you selected a closed polyline and specified a count of cells, some measure of 'wildness' and perhaps a boundary thickness and it automatically generated Voronoi cells to fill the area, automatically clipped nicely to the boundary.  I'm sure that this would be used by many people wanting an elegant way of lightening a structure.  Did you build your plugin in Perl?  I would love to know how!

Note that in the absence of such a tool, you can simply take an existing pattern in a layer on its own and clip it and filet it.

Best wishes,

Bob

Offline mikek

  • Ewok
  • *
  • Posts: 31
    • View Profile
Re: Voronoi Table Lamp
« Reply #9 on: May 24, 2014, 03:35:49 am »
Hi Bob,

Thanks a lot for the data points. I'll give that a try. Earlier today, in trying to understand how to achieve polygons
with different number of sides I traces the points off a voronoi picture on a web page and assigned x,y coordinates
to the point right from the green engineering graph paper and it worked. I got very nearly the same shapes as
in the web picture.  So that led me to understand that the shape, size, arrangement, etc are just a product of
x,y placement. Good to know. Oh, and clipping is necessary.

Now, as for the programming. I did something similar to what you did. I created a Perl/Tk window to display the
voronoi polygons and assigned different colors to them to make them stand out better. So far the graphic part
is very crude. I haven't even dealt with scaling the image yet. But it works to see how the voronoi is shaping up.

The plugin. I started by trying to create it with python which I know next to nothing about. I got within one
statement of getting it operational, but when it failed to compile on cambam due to a missing "split" command,
I just gave up. If basic string tools are missing, I just didn't want to fight that.
So I switched to C#, another toolset I know next to nothing about. %-) But after a lot of successful google searches
on how to do things the C# way :-) I succeeded in creating the plugin. The plugin is responsible for just loading
the polygons from a file and installing them as polygons in cambam.  I've just about got an instruction/cheatsheet
written to describe the steps needed to deal with the clipping/cropping issue you pointed out. If the polygons
you're loading are good to go without editing then that's the easy case. But, as I have been discovering with my
testing of random arrays of points, the good part is in the middle of wild and crazy polygons around the edges.
In that case there's a process to clip the polygons and then repair all the ones around the outside edges.
Not hard, but tedious. I'll include pics.

It sounds like you're interested in the plugin, so I'll upload it in the next day or so. I have made a fair bit of effort
to insure the polygons file is of proper format.  We'll see how long it takes for someone to find a corner case
I don't handle. I want to add a readme file with some info on the polygons file format to follow.
My perl program still needs a bit of work, not ready for prime time just yet.
I sure liked your ideas about an all inclusive plugin to do it all. Is the voronoi math module available in C#?
Might be interesting to try that some day.

Mike

Offline BR52

  • Wookie
  • ****
  • Posts: 368
    • View Profile
Re: Voronoi Table Lamp
« Reply #10 on: May 24, 2014, 13:19:55 pm »
Hello Mike

As you said the key word that C #, you received a gift.
Since the creation of Cambam was done in C # and also the plugins in C #.
You need to install the Visual Studio 2010 Express C #.
Annexed an example.

   Armando
« Last Edit: May 24, 2014, 13:22:32 pm by BR52 »

Offline mikek

  • Ewok
  • *
  • Posts: 31
    • View Profile
Re: Voronoi Table Lamp
« Reply #11 on: May 26, 2014, 07:46:46 am »
Hey thanks Armando. That voronoi project in C# is goin to take a lot of study.

Mike

Offline mikek

  • Ewok
  • *
  • Posts: 31
    • View Profile
Re: Voronoi Table Lamp
« Reply #12 on: May 26, 2014, 08:07:57 am »
Hi Folks,

I've got the initial version of my "Load Polygons from a File" plugin  ready to share.
This plugin can be used as the back end of voronoi polygons creation to get them
loaded into CamBam. However, this plugin is completely independent of voronoi and
could be used to load polygons from any source as long as the file format is correct.

I'm including a README file that explains how to use the plugin and a description of
the process to edit the loaded polygons for CamBam use. The README also
documents the format of the polygons file that the plugin requires.
Feedback is welcome. This is the first project I've ever done on C#. It was very tuff
to figure out the CamBam class libraries. I sure would like to see more documentation
on them.

Enjoy,

Mike

Offline macbob

  • Storm Trooper
  • ***
  • Posts: 189
    • View Profile
    • Bob Mackay
Re: Voronoi Table Lamp
« Reply #13 on: May 26, 2014, 15:35:01 pm »
Hi Mike,

I have yet to try this plugin, although I read your readme.  A plugin to import lines from a file does seem to be a better approach than my lines_to_cb program, which is something of an abuse of the .cb xml file format.  See http://www.cambam.co.uk/forum/index.php?topic=3279.msg21014#msg21014.

It is strange to me that CamBam supports importing text files containing STL polygons for surfaces (via the Draw->Surface->from text file) but does not seem to do the more simple-minded import of lines and polylines.  Unless I am missing something.

Bob

Offline mikek

  • Ewok
  • *
  • Posts: 31
    • View Profile
Re: Voronoi Table Lamp
« Reply #14 on: May 26, 2014, 15:52:09 pm »
Hi Bob,

Yes, I suppose XML is the more Proper format to have used. But I was in a bit of a hurry to get
something working and at least for this first pass I just kept it as easy and simple to produce from
perl.

I'll have to do my homework and explore your xml tool and read up on the threads you mentioned.

I'll post the source files soon as I clean them up a bit. Hopefully someone will point out all the stupid
methods I used to get the job done and tell the right way to implement things. As it is, I had to
resort to several type cast operations which seems to me to be a  cheat and violation of the
software standards of conduct. :-)  But, ya gotta do what ya gotta do to get'r done!

Mike