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.
Tags:
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.
This is great. Dumb question, how to constrain this to a boundary curve
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.
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.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by