Grasshopper

algorithmic modeling for Rhino

I'd like to share here a few new examples of scripting with the Kangaroo2 library.

Starting with some custom goals (these will probably be included as standard components in later releases, but I'm posting them here first for anyone interested in seeing the code), to be followed by some examples of custom loops.

First, a simple wind goal. This is one that existed in Kangaroo 1, but I hadn't got around to making a version for K2 until recently. It is very similar to the pressure goal, except here the magnitude of the force is dependent on the orientation of the face relative to the wind vector.

The cross product of 2 edges of a triangle give us a vector in the direction perpendicular to its face, and with a length proportional to the area. This is exactly what we need for the pressure. To convert that into something dependent on the wind, we take a dot product with the wind vector (so the pressure will be zero when the face is exactly aligned with the wind, and at its maximum when it is perpendicular to the wind).

Finally, we divide the result over the 3 vertices of the triangle.

Views: 3562

Attachments:

Replies to This Discussion

Here is another custom goal - breakable lines:This acts just like a length goal until it is stretched beyond a certain limit, at which point it splits into 2 separate segments.

Goals cannot actually themselves add or remove particles to/from the simulation, so here we get around this by making 2 extra vertices per line when it is created, which are both kept at the midpoint until it breaks. Note also that we have to have a reset function for this goal, connected to the same toggle we use to reset the simulation.

Attachments:

Hi Daniel,

an error has occured like below, u have any clue what could be the reason?

Error (CS0506): 'Script_Instance.BreakableLine.Output(System.Collections.Generic.List<KangarooSolver.Particle>)'

especially on line 145!

..and here's an example of a script which actually modifies the iteration rules, and adds new particles as it goes. It takes a starting polyline, and gradually grows all the segments, while preventing self collision, and then splitting segments once they get over a certain length.

Attachments:

This is great. Dumb question, how to constrain this to a boundary  curve

Hi Mark,

Here is the script changed to keep the curve on a mesh. This will also work to keep it within a planar outline.

Attachments:

thanks Daniel. Its magic.

Hi Daniel,

and I also noticed an error of this Definition:

Error (CS1061): 'KangarooSolver.PhysicalSystem'

It seems something about 'GetPosition' issue...

Here is a simpler example of some custom iteration:

This adds points one at a time, keeping them on a mesh, with collisions between them.

The script here is much simpler than in the above example, because instead of keeping the particle system and modifying the indexing, the only thing it stores from one iteration to the next is the set of point positions. At each iteration it makes a fresh simulation and takes one step.  

Attachments:

Really cool, as always.

Thanks for sharing.

This is beautiful. I was working on a buoyancy simulation problem before and I had to script my own simulation in GH, this custom iteration can perhaps simulate that.

Thanks Victor - yes, buoyancy would be another good thing to add.

In K1 there was a force which applied pressure to triangles, with a magnitude dependent on the distance of their centroid below the waterline.

Hi Daniel,

super cool, thx again!

It glad to hear that buoyancy component going to add!! I am curiosity if this is about the aero dynamic or more about up thrust?

However, it must very interesting to see it in K2!!

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