Grasshopper

algorithmic modeling for Rhino

Rope-Length Minimization with Kangaroo

I'm a Mathematician who studies knots, among other objects. One of the ways to study a knot is to keep the radius of the rope used to tie it fixed, while shrinking its length as much as possible. This process is called "Rope Length Minimization." After a few days of experimenting, I've been able to implement this with Rhino/Grasshopper/Kangaroo! Here's a little animation of a randomly drawn knot shrinking to it's rope-length minimizer:

Here's the grasshopper definition: RandomKnotMinimizer.gh

It basically works by converting the knot into a set of straight lines (i.e. finding a polygonal approximation). Then it converts each of those lines to a spring with zero rest length. At the same time, a set of forces are applied that keep every segment of the knot at least one unit of distance away from every other segment. The program is then put into motion while the strength of each spring is gradually increased.

I'd love to see other strategies to do similar kinds of things. I thought the Line-Line Kangaroo component can be used to repel each edge of the knot away from every other, while keeping their lengths fixed, but I couldn't get that strategy to work.

Views: 2870

Replies to This Discussion

Thank you, David!
And also a big thanks to Nik!
You are Grasshopper TopGun team members :)

Very important and enabling work, I'm blown away at the power of it. Having Kangaroo do what I want it to I often lack the time to pursue so it's great to see this example.

I've turned triangular meshes into knots, often single rope ones, though more often a small collection, or a single huge knot with a few somewhat random appearing independents:

http://www.grasshopper3d.com/forum/topics/celtic-bunny

Thanks!! I love your woven Bunny!

I want multiple curves now though since things like the bunny or just a triangulated sphere mesh end up with a handful of curves instead of just one and playing with a single curve of a sphere mesh knot just collapses into an overly simple knot since it's barely self woven itself, if at all:

I'm not sure how to replace the necessary number slider either with a timer perhaps, for massive knots that are likely to be too slow for the slider to handle well, and finally I wonder if Kangaroo 2 can do the same thing, since it may be faster.

Works fine with a timer if I fix stiffness at 100 instead of sneak up on it with a slider. Overly high stiffness can cause tunneling of string through string due to overly high kinetics and damping doesn't seem to help. Works fine with even low stiffness like 20 or even just 5.

(1) Double clicking Kangaroo 1 gives you the VCR control I remembered, and no timer is needed.

(2) You are using slow pipe instead of fast mesh pipe.

(3) For multiple curves I need merely flatten the inputs to Cross Reference and flatten the Force Objects input. I also had to divide the curves according to how long they are to capture their form in your polylines, since they vary in length.

(4) Too slow on such a huge system as I just posted. That leaves manually built simple triangular meshes and a few simple triangulated polyhedra from the Rhino Polyhedron plug-in.

(5) OH MY GOD WOW IT WORKS REALLY WELL AND AFFORDS MORE INTERESTING PHYSICALLY BULKY RESULTS THAN MY INITIAL THIN STRING KNOTS!

That's 10 woven loops, it turned out, from a biscribed pentakis dodecahedron.

Attachments:

A single string tetrahelix knot collapses nicely:

It not perfect since there's some intersections perhaps caused by Kangaroo forces adding up and overpowering local resistance to keeping lines apart, or maybe I didn't use enough polyline segments and so there's a kink in the underlying polyline that I made the interpolated curves from the points of. Looking at the polyline, indeed that's the issue, and the polyline is actually rather crude but that makes it faster.

Though there was a gap with these perfect octahedra, I point edited it as meshes to close the little Geometry 101 gap and the relaxation under tension should give a symmetrical result anyway.

Beautiful, Nik!

One thing that's bothering me about the algorithm is that as the individual sticks shorten, at some point they start to repel each other in undesirable ways. For example, in a simple knot (one strand), the algorithm turns the knot into line segments, but doesn't create forces between consecutive lines. However, there will be a repulsive force between line n and line n+2 when their lengths are less than half of the radius of the tube around them. Lines n and n+3 repel each other when their lengths are less than one-third of the tube radius, etc. I think that's why running the script on the trefoil produces this:

That's clearly not as tight of a knot as you would hope for. I'm not sure how to get around this. The problem is that you want the line-line repulsive force to only act in a direction orthogonal to each line, but I don't think that's how it works.

Maybe one fix is to shrink the tube radius as you shrink the knot, while at the same time enlarging the whole picture. Like a renormalization process. Not quite sure how to implement this, yet.

Don't feel so bad, Reality must calculate billions of atomic coordinates as voxels to do same, and then all you get is a snake that won't play nice like clay instead of biting you to inject pain amplifiers.

Simple icosahedral triweave knot.

by dfgdsfg

by dfgdsfg

by Evan

by Evan