By treating all of these within the common language of force vectors Kangaroo allows live interaction between them.
The input to Force objects needs to be a flattened list. (To flatten the input right click on the name and select Flatten).
All the different possible types of forces are covered in more detail later in this guide.
These can be used to keep points fixed in a certain location. No matter what forces are applied to them they will not be moved by Kangaroo. However, you can still move them in Rhino to interact with the simulation as it is running.
The minimum distance between separate points. Points closer than this will be consolidated into one.
How far through time the system moves at each iteration. Smaller values will result in a more stable, but slower simulation. Stronger forces and stiffer springs require smaller timesteps.
The number of iterations calculated between each time the solution is drawn on screen.
A simple constraint which can be switched on or off preventing particles moving below Z=0
This is much faster than Brep collision.
A force on all particles resisting their motion.This is essential to make a system settle down to a static equilibrium position. If drag is too low, the system will oscillate for a long time, if it is too high, the particles will move slowly.
How elastic collisions between particles and the floor are. If 1 then particles bounce back to the height from which they were dropped, if 0 they do not bounce at all.
How much horizontal velocity is conserved in collisions between particles and the floor.
Sound effects. This feature is disabled in the current version.
The integration method used by Kangaroo to calculate new positions for the particles.
Utilities
Kangaroo contains a remove duplicates tool :
which can be used to clean up lists of points. It has a tolerance setting which you can set to some small value (such as 0.01) so that any points closer than this will be combined into one.
RemoveLines
InterConnect
Running the simulation
To start and stop the simulation you need to attach a Toggle (Parameters>Special>Boolean Toggle) to the
SimulationReset input of Kangaroo. When this is set to True Kangaroo does some initial pre-calculation and matches all the inputs to the appropriate points. When it is set to False the simulation moves forward one iteration every time the grasshopper solution updates.
To make the simulation continuously update you need to attach a Timer component (Parameters>Special>Timer). Drag the dotted line from the timer to any part of the Kangaroo component. The timer has an interval setting which controls how long it waits between updating the solution. Right click and change this interval to 1ms to get the maximum speed.
Displaying the Grasshopper canvas takes quite a lot of memory and slows down the simulation considerably. To avoid this you can minimize it while running your simulation.
Instead of double-clicking the Timer component to turn it on and off you can double click the global toggle which will appear on your Taskbar the first time you use the Timer.
Newton's Laws
The change of momentum of a body is proportional to the impulse impressed on the body, and happens along the straight line on which that impulse is impressed
(illustration)
This law is probably most familiar to you as
F = ma (1)
force = mass acceleration
Which we rearrange to get a=F/m (2)
Kangaroo works by finding the total force vector F for each particle by adding up all the different forces acting on it, using Newton's second law to get the acceleration, and numerically integrating the resulting differential equation of motion over time to find new positions for all the particles.
Note that in Kangaroo mass is not automatically associated with weight.
More massive objects take more force to change their velocity.
Weight is the force on an object due to gravity.
In real life an object's weight is proportional to its mass.
In Kangaroo you can easily make this the case, or you can assign them completely independently (for example in order to test specific loading cases).
It is possible to assign a particle zero weight, but giving a particle zero mass would result in a division by zero in equation (2) above and cause an error.
You do not always have to specify values for mass - if no specific input is provided, all particles will be assigned a default mass of 1.
To assign a particle a particular mass, or give it an initial velocity, use the Particle component.
To include the effects of gravity and give a particle weight, you must apply a Unary force to it.
(illustration)
To every action there is always an equal and opposite reaction
(illustration)
This is why Kangaroo uses lines to input forces. Each force is an interaction between a pair of particles - the endpoints of the line. The force acts in the direction of the line and is added to one particle and subtracted from the other.
Unary forces are an exception to this - they only apply to single particles. However, what we are effectively doing here is pairing the single particle with another infinitely distant and infinitely massive particle - a reasonable approximation to the centre of the earth for many practical purposes.
Every body persists in its state of being at rest or of moving uniformly straight forward, except insofar as it is compelled to change its state by force impressed
(illustration of vector summation)
If the forces on a particle sum to zero then it will not accelerate.
Conversely, while the forces do
not sum to zero, the particle's velocity will continue to change.
If we include in our simulation some form of
friction or
drag then all particles will continue to move until they eventually settle in an equilibrium position where the net forces on each particle sum to zero.
(I will eventually add a total KE output. We could then use this to tell the simulation to run until it drops below some given threshold.)
Discretization
Because the geometry of a spring in Kangaroo is determined by just 2 points, it can only ever be a straight line.
To make
flexible elements we must first
break them up into smaller pieces and model each segment as a separate spring.
Here we make certain simplifications, for example, when modelling a hanging chain we treat it as though all the mass is concentrated at the ends of each segment, when in reality it is distributed over its length.
However, provided some care is taken with how the masses and forces are assigned then these lumped mass models can often provide a decent approximation of continuum mechanics (even when quite coarse subdivision is used).
Cables
Cables can be divided up into segments either in Rhino or in Grasshopper
(illustration)
Dividing the curves in Rhino might be easier for those less comfortable with Grasshopper, but doing it in Grasshopper can make altering the definition easier.
a flexible cable is modelled as made up of multiple straight segmentsSheet materials - membranes, fabrics, paper etc.The simplest way to make a sheet material in Kangaroo is to use a grid of springs.
A grid of zero rest length springs will behave something like a soap film - trying to minimize area. So if you don't restrain the edges it will shrink down to nothing. If you wanted to avoid this (for example if you are simulating tensioned fabric), you could use a rest length for each spring which was some multiple between 0 and 1 of it's start length (illustration). You could also increase the stiffness of springs around the outside of the mesh to simulate edge cables.
For catenary structures where you want to simulate a hanging grid of chains you may want to make the rest length
more than the start length to give it some slack.
To more realistically model the behaviour of cloth you may also want to add shear springs - diagonals which stop each square from deforming into a diamond shape.
Different stiffness values can be used for the main square grid springs and the shear springs for different cloth properties.
There are a number of choices for how these diagonals are added - 1 or 2 per quad, aligned or alternating. I haven't tested much yet how this choice affects the behaviour.
You can also add bending stiffness - (useful for some cloth behaviour and particularly for sheet materials like paper or metal). The typical way to do this is to connect springs between alternate points in the grid, but a better way is to use the bending elements described in the section below on rods.
Rods
Bending resistance works with sets of 3 points. It will try to keep those 3 points in a straight line. So to model an elastic rod you need to input the 1st 2nd and 3rd nodes, the 2nd 3rd and 4th nodes, etc
(illustration)
To fix the tangent of a rod simply make 2 points at the end anchor points. To just fix the end position only use one anchor point.
There is currently no way to simulate resistance to torsion for 1D elements in Kangaroo, so it is as though the rod is free to twist about its own axis at the constrained ends. (Though you can make solids with torsional resistance as described below).
Solids
(more to add here)
There are probably many more useful discretizations to be invented. Because this part of things happens in grasshopper outside of the kangaroo code, anyone has the control and freedom to explore this.
SpringsIt might seem odd at first to simulate entire structures with springs - but we are not just talking about the kind of springs in car suspensions and mattresses. Even the stiffest materials stretch and compress when we apply forces to them.
Hooke's law says that the force exerted by a spring is directly proportional to the amount its length differs from its natural or rest length.
This is a simplification, but often a good approximation for many materials in ordinary use.
Note there is no Kangaroo input for the start length of a spring - it simply uses the length of the curve input to springs.
The rest length (also called natural or slack length) of the spring is the length it 'wants' to be.
If you do not supply a value for rest length it defaults to 0. Often you will want to make the start length the same as the rest length - which you can do by simply connecting the curve to the rest length input (illustration).
You can also include a multiplier, so that the rest length is some multiple of the start length. If this multiplier is between 0 and 1 it will be like pre-tensioning the spring. (illustration)
SpringThe top graph represents the force calculation that takes place within Kangaroo.
The distance at which the line crosses the horizontal axis is the natural length of the spring.
The stiffer the spring, the steeper the line.
The bottom graph shows how the potential energy varies.
Note that its speed(kinetic energy) is greatest when its potential energy is lowest and vice-versa.
Without drag it would keep sliding up the slope to the same height on the opposite side as energy was converted back and forth between potential and kinetic.
When drag is added to the system these oscillations decrease in amplitude until it settles in a position where the potential energy is
minimized. This is the essence of how physics-based
optimization in Kangaroo works.
Zero rest-length spring
Springs with a natural length of zero are often useful. For example minimal surfaces can be roughly approximated by treating all the edges of a mesh as zero-length springs.
Cut-offs
Balls (Spring with positive Cutoff):The SpringCutoffs input lets you specify a distance beyond which to ignore the effect of the spring.
If you use the same value for SpringLength as for SpringCutoff, then the particles behave like a pair of solid balls which exert no force on each other when they do not touch, but push apart when they overlap (ie when the distance between their centres is below that value, which should be equal to the sum of the radii of the 2 spheres) .
'Hamsterball' (Spring with negative Cutoff):
If the value you supply to SpringCutoffs is negative, then the force due to that spring will only have an effect above that distance. When you make the Cutoff value the negative of the SpringLength value, this is like one sphere being inside another, with the value equal to the difference between their radii.
Cut-offs for Power Laws work in exactly the same way as for springs.
They can be particularly helpful when using power laws with a larger negative exponent (eg -3 or -4).
When the force increases very steeply at short distances (see the section on Power Laws below) it can cause particles to 'explode' apart when they get too close. A small negative cutoff (say -0.1) can help avoid this.
Power Laws
This shows a Power law force with exponent -1, which means that the strength of the attraction is proportional to the inverse of the distance between the particles.
A basic math reminder:
Using a more negative exponent (such as -2, the familiar inverse-square law) would mean a force which increased more sharply at short distances and fell off towards zero more quickly at larger distances. (illustration)
Power Laws in Kangaroo only accept integers as exponents- because raising a number to an integer power is much quicker to compute than raising it to an arbitrary rational number, and most known real physical forces have integer exponents.
*edit - why is this ? are there any known forces with non-integer exponents?
If the strength of a Power Law is positive then it is repulsive - it tries to maximize the distance between the particles.
If the strength of a Power Law is negative then it is attractive - it tries to minimize the distance between the particles.
Tip - When using attractive power laws with large negative exponents you may find it is useful to include a small negative Cutoff value. This is because otherwise at very short distances the force increases so sharply it can cause the particle to dramatically overshoot.
Other Forces
(descriptions coming shortly)
Planarization
Pressure
Constraining to a surface
Brep Collisions
Equalization
Rockets
Combining forces
* include something about combination forces such as Lennard-Jones here
Unary Forces
These have already been covered a bit earlier in the section on Mass and weight.
They can also be used to add other forces which are not dependent on the distance between particles, such as simple wind loads.
Drag
Drag is a force which acts on particles opposing their direction of motion. The faster the particle is moving, the greater the force.
Kangaroo has several sorts of damping :
Global damping - which is applied uniformly to all particles in the simulation. The 'Drag' input allows you to set the strength of this. Values between 1 and 30 seem to work well. You may find you need to experiment with different values to get the effect you want. For example when form-finding a catenary roof, if the damping is set too low, the form fall then bounce back up and oscillate for a long time before settling into the desired equilibrium. If damping is set too high it wall fall very slowly, as if through treacle.
Spring Damping - This force is a setting for springs, which also opposes the movement of the particles, but only in the direction of the spring. So for example a horizontally stretched spring with spring-damping allowed to fall freely under gravity will still reach the ground in the same length of time, although its length oscillations will reduce.
(Entropy, energy loss...)
Outputs
Explanation of Geometry Tree to go here
Troubleshooting
-The simulation oscillates wildly or explodes
Because Kangaroo is numerically approximating continuous* behaviour with discrete time steps, errors can occur. Usually these errors remain very small, but when dealing with very stiff springs, particles sometimes overshoot in a way that builds up rapidly, causing the whole system to fly apart.
The solution is either to use softer springs or to decrease the timestep (try reducing it by a factor of 10, eg from 0.01 to 0.001). Increasing Drag or Spring Damping can also help. Smaller timestep means more calculation steps for the same amount of movement, so the simulation will run slower. One way to counteract this is to increase the value of SubIterations (typically by the same factor you reduced the timestep). This means that multiple calculations of the particles' positions occur between the ones which you actually see on the screen.
* Well it seems continuous, but is time really continuous or discrete ? That's a question for another time!
Other sections to add:
Tracing particles
producing animations (slider)
speedup tips (system process priority)
References/Further readingBaraff & Witkin's Siggraph '97 course notes
Physics-based generative design
Ramtin Attar, Robert Aish, Jos Stam, Duncan
Brinsmead, Alex Tessier, Michael Glueck,
Azam Khan
http://www.autodeskresearch.com/projects/complexconstraintPhysically based deformable models in Computer graphics
Andrew Nealen, Matthias Müller, Richard Keiser, Eddy Boxerman, Mark Carlson
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.124.4664&rep=rep1&type=pdfJeffrey Traer Bernstein's Traer Physics
lots more to add here
Future development plans
new forces to add:
vortex filament/driveshaft/hingespring
To rotate one particle about a line segment. Could be Biot-Savart like, or like PLaw where user has a choice of how distance affects strength. Useful for wheels, folding...
alignmentalign 2 line segments which are not necessarily contiguous. could be used for flocking
bending with non-straight rest angle
eg to constrain 2 segments to be perpendicular
windarea dependent like pressure, but projected onto a wind vector
air resistance
like wind, but opposed to the motion of the triangle
shear
2 line segments try to keep the same normal plane
plate/shell elements ?
This is a tricky one - would really appreciate suggestions here...
breakable springs
Add/improve integration methods
Total Kinetic Energy output (and maybe an option to run the simulation until this falls below a certain level)
If you have any suggestions or requests for other forces to add, please let me know