Grasshopper

algorithmic modeling for Rhino

Hi there!

the title is already clear, how can I obtain a rectangular grid inside a non regular shape?

thank you for help!!

Views: 6405

Attachments:

Replies to This Discussion

Here is one possibility, though many of the grid "rectangle" curves along the edges are partial, open curves because of trimming.  They can be closed, or a different method may not create them in the first place.

Attachments:

This is the simplest way that comes to mind at the moment to get subsurfaces from the grid; the sequence of the grid is lost, unfortunately, due to 'Flatten'.  It doesn't work to use 'Sort Points' on the area centroid of the subsurfaces, though, because their trimmed shapes move those points out of alignment...

Attachments:
If you want no cut you will have to measure all lengths of border find the length that gives an integer at the division.
If you want rectangles sort curves in X and y direction.

yes, the idea is to have no cut and square instead of the rectangle (having a rectangle grid with no cut would be already good starting point ).

I know I should find the length giving an integer, I did it manually, but I wonder how I can optimise the process.

Attachments:

What?

the title is already clear

No sir, not clear at all.

Joseph, he is French like me. Sometimes it is difficult to translate.

The trick that he needs is to convert all the lengths in integer (with a certain precision) and then find the greatest common divisor GCD and then cut the shapes in square having the length egal to the GCD. Not sure it is more clear. 

https://en.wikipedia.org/wiki/Greatest_common_divisor

I will give it a look tonight, there is a function for the GCD in maths.net numerics.

Thanks for the explanation.  I understand GCD, just not how it applies in this case?

The revised Rhino file (with a completely different shape?) shows only two dimensions, both in 'Y', nothing in 'X'.  "1061" is a prime number so there is no GCD with it and any other dimension!?  Even if there were, that's only one direction, what about 'X'?

YES, gcd is the way, but I wonder if it exists in a more sophisticated way.

thanks anyway (reducing as much as possible the ''certain precision'')

Now it's time to pack... heeheh how  can you deal with a similar shape but having a square grid?

thank you!!

Attachments:

Hello

here a more "sophiscated" way a bit long but just with Grasshopper components (I hope). It uses an evolutionary solver Galapagos. You will have to define a maximum number of squares and a minimum which can go inside the area defined by the curve. Then the solver will try to minimize the area not covered by squares.

There are 3 variables, the size of the square and the position. All sliders are normalized so they don't represent the real size. 

As it is my first use of Galapagos I don't know all the functions. There must be some optimization. 

There are also some problem with precision of inclusion on points => lower the tolerances in Rhino.

I put here a simple example with 2 best solutions at the extremes. And a more complex curve with round edges.

Attachments:

Galapagos!?  Oh my.  Wouldn't it make a lot more sense to guarantee that all the perimeter edges have lengths that are integral multiples of the grid size?  We are getting a little silly here... but I'm not French. ;)

This version has sliders for 'min' grid size, 'max' grid size and 'count' (number of intervals to test between the two).  It generates a 'Series' of grid sizes, tests them all using the previous algorithm, then compares the 'Area' of each result with the original perimeter.  The smallest difference determines "best fit grid size".

Guess what?  In almost every case I tested, the smallest size won!  No surprise, though I did eventually find slider settings where that isn't the case.  It's a lot of effort for a dubious approach, AFAIC.

P.S.  This is a bit of surprise...  With 'min=60', 'max=100' and 'count=10', "best fit grid size" = 76.  So the algorithm is valid, eh?

Attachments:

Now it's time to pack... heeheh how can you deal with a similar shape but having a square grid?

That approach makes more sense to me.  This code lets you change the 'grid size' (square as written but could easily be rectanglar), then returns the cells that fit within (or intersect) its boundary curve:

Attachments:

Extracting the perimeter curve (yellow) to create a single boundary surface ("Trimmed Surface") instead of a bunch of squares joined as a brep:

P.S.  The additional steps degrade performance so keep them disabled for better response to slider changes.  Small values for 'grid size' results in far more grid cells, which also degrades performance significantly.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service