Physical motion and simulation

Back to Codes of Nature


Author: Zsófia Ruttkay Version: 1.0 Date: 25.2.2009

In the previous section we orchestra ted motion by directly defining and generating the speed. We used some functions and noise to mimic the observed motions, but did not bother about their causes. In nature it is some force which makes things move: gravitation, the force of wind, the muscle force of animals,... The living organs are more or less elastic, force also changes their shape.

There are hundreds of computer graphics articles and softwares written to simulate e.g. hair, or fluids, or the human muscles. We shall not dig into any of these - but learn about three basic principles. Using the laws of Newton will allow you to create smooth falls, bounces, glides ... and your own special effects with particles. By understanding the working of springs , you can use the principle to create elastic creatures and smooth reactive motions. Finally, creatures - from ants to birds - often move around in groups. Using artificial 'social forces' is the basis to simulate flocking behaviour .

Bouncing balls - gravity, collision and friction

../Sketches/CourseSketches/Physics/Fall1/Fall1.jpg Dropped ball falling and bouncing back

src: CourseSketches/Physics/Fall1/Fall1.pde

change of speed by gravity
bouncing without friction
../Sketches/CourseSketches/Physics/Fall2/Fall2.jpg Ball shot with some initial speed
Gravity makes the ball fall down, the x-directional speed makes it move forward. When hitting the wall, the x-speed direction changes, but not the amount - no friction thus.

src: CourseSketches/Physics/Fall2/Fall2.pde

change of speed by gravity
bouncing without friction
../Sketches/CourseSketches/Physics/Fall3mr_100/Fall3mr_100.jpg Shooting upwards a single ball
With random initial x and y directional speed (printed), force only gravity.Trace of fall is shown.
src: CourseSketches/Physics/Fall3m/Fall3m.pde

Shooting upwards 100 balls at once
src: CourseSketches/Physics/Fall3mr_100/Fall3mr_100.pde

loop(), noLoop(),
reinitializing variables by mouse click
../Sketches/CourseSketches/Physics/Fall4mr_100/Fall4mr_100.jpg Balls bounce and roll on ground
Once the y speed is 0, the x speed keeps the balls rolling on the ground - with friction slowing them down to stop.

src: CourseSketches/Physics/Fall4mr_100/Fall4mr_100.pde

change of speed by gravity
bouncing without friction

Springing

../Sketches/CourseSketches/Springs/Mod50_13_1/Mod50_13_1.jpg Spring pulls an object
Once the mouse is released, the red stretched spring pulls the parcel to the target location.

src: CourseSketches/Springs/Mod50_13_1/Mod50_13_1.pde


spring physics
../Sketches/CourseSketches/Springs/Mod50_13_2/Mod50_13_2.jpg Spring pulls an object with mass
m is the mass of the object (seen by size too). Experiment with the effect of the mass on the spring's pulling force, and thus the motion.

src: CourseSketches/Springs/Mod50_13_2/Mod50_13_2.pde

spring physics
../Sketches/CourseSketches/Springs/Mod50_17/Mod50_17.jpg Balls connected by springs - a worm moving
Each small spring is pulled by the previous one. The chain of forces causes a worm-like motion. Experiment with changing the characteristics of the connecting springs - each instance of the Spring2D class.

src: CourseSketches/Springs/Mod50_17/Mod50_17.pde

Class
strings stretched in any direction
../Sketches/CourseSketches/Springs/Greenberg_11_12_Worm/Greenberg_11_12_Worm.jpg A worm wondering around
Explore this worm example from Greenber's book.

src: CourseSketches/Springs/Greenberg_11_12_Worm/Greenberg_11_12_Worm.pde

Class
../Sketches/CourseSketches/Springs/Greenberg_11_15_SpringyDude/Greenberg_11_15_SpringyDude.jpg A creature with soft deformable body
Frame of the body is a pentagonal skeleton of springs.

src: CourseSketches/Springs/Greenberg_11_15_SpringyDude/Greenberg_11_15_SpringyDude.pde


Flocking

../Sketches/BookByReasAndFry/Synthesis/_14_pond/_14_pond.jpg Pond - Synthesis_14
Small fish as boids swim around, form groups, avoid the big fish, get disturbed by mouse click, ...Coding of such behaviour simulation is beyond this course's scope - but understanding the principles and experimenting with it is not.

src: BookByReasAndFry/Synthesis/_14_pond/_14_pond.pde

Class
boids, steering rules, Bezier splines

On-line learning resources

Daniel Shiffman's page on steering with examples

Further links

Bouncing back from non-horizontal ground examples at the processing site (also in local Examples)
Bouncing back from bumpy ground example at the processing site (also in local Examples)
Bouncing bubbles example at the processing site (also in local Examples)
Spring examples at the processing site (also in local Examples)
Sodaplay - highly recommended Flocking example at the processing site (also in local Examples)
Simple particle system example at the processing site (also in local Examples)
Smoke particle system example at the processing site (also in local Examples)
Smoke example at the processing site (also in local Examples)