Grasshopper

algorithmic modeling for Rhino

What I'm aiming to do is create an attractor that causes the cells of a hex grid to change from a full 6 sided hexagon, to 5 sides, to 4 sides, etc.

The end result should leave something similar to my sketch where the further the hex cell is from the attractor, the less sides it has. As the catch, the cells still need to connect by at least one line for fabrication. 

My first attempt was close but a polygon cannot have less than 3 sides, so running it through that component wouldn't work. I'm now trying to interpolate a curve(s) through each cell independently, but still affected as a whole. 

Any assistance would be much appreciated!

Views: 753

Attachments:

Replies to This Discussion

Hmm ... I did a "similar" thing (using curves not points) a million years ago.

Have some fun

Attachments:

Thanks! I wonder what life was like a million years ago... ;)

better

So I've never scripted before, and am clearly new to grasshopper, could you make a suggestion about how to randomize which side of the hex cell segments that appear?... with the constraint that there are no floating lines so that each line is connected somewhere like my initial sketch... much thanks!

Er ... that's Catch 22: It's very easy provided that you can script ... but you can't (yet).

For instance

foreach(Polyline poly in polyList){

   List<Line> segments = poly.GetSegments().ToList();

   segments = GetRandomElements<Line>(segments, rnd.Next(0,6));

}

public static List<T> GetRandomElements<T>(IEnumerable<T> list, int elementsCount)
  {
    return list.OrderBy(arg => Guid.NewGuid()).Take(elementsCount).ToList();
  }

Found some minutes to chop code (*) from here and there (engineers do that Sir all the times) and create a Frankenstein type of stuff that is "suitable"(**) for the scope. Added a rollTheBones and takeRandom options.

(*) code quality is awful due to some recent VERY unfortunate Formula 1 results.

(**) if you buy this you can buy anything.

May the Force (the dark option) be with you.

Attachments:

Yikes ! put this into the right place please

And the usual update (worst, slower, more bugs == way better).

Attachments:

Much thanks my good sir!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service