The Lorenz Bubbles

In this interesting visual effect, disssolving and shrinking bubbles are traveling along the trajectories of the Lorenz attractor. Click on the image below to open the applet in a new window.

Download

  • Download all the source files corresponding to this experiment: bubbles.zip

Comments About the Code

What you see in the Flash movie that opens when you click on the image above is an animation of the Lorenz Attractor drawn in the form of bubbles which become loose and float away. Here we are illustrating how the same basic code used in our earlier rain animation tutorial can be modified to produce a different effect. You can find the earlier tutorial at Rain Animation with Splashing Raindrops - AS3 Flash CS4 Effect. More information about the code can be found in the above tutorial. Here, we simply make some comments on what changes have been made.

In the Rain Animation with Splashing Raindrops - AS3 Flash CS4 Effect tutorial, we presented a RainDisplay class which drew raindrops on a canvas and animated them according to initial velocities and gravitational acceleration. The raindrops were members of the LineRaindrop class.

Here, we have modified the RainDisplay class to create a new RainDisplayBubble class, and modified the LineRaindrop class into a BubbleDrop class.

Of particular interest is a new set of parameters for the bubbles which define how their shape changes with time. The changes in radius are defined by an envelope, an idea borrowed from sound synthesis. (In sound synthesis, an envelope defines how, for example, the volume of a sound increases, sustains, and then decays back to silence.) Each BubbleDrop has its own envelope parameters. The radius values and time values (along with some randomization values) are set by the setEnvelope function. Play around with these values (in the onEnter function in the main ‘fla’ file) to see how they affect the animation.

For added interest, the bubbles are added to the display over time according to the Lorenz equations, which define a continuous dynamical system which exhibits chaotic behavior. This results in a trail of bubbles which follows a seemingly random trajectory.

About Lorenz Attractor

The Lorenz equations are one of the earliest studied examples of what is known as a chaotic dynamical system. The equations are a set of three differential equations in three coordinates x, y, z, and their rates of change with respect to time:

dx/dt = a(y-x),
   dy/dt = x(b – z) – z,
   dz/dt = xy – cz,

where a, b, and c are given constants. These equations can be thought of as describing the continuous motion of a particle through three-dimensional space. To approximate this continuous motion with our Flash simulation, we need to consider the motion of the particle over a very small time period Δt (in our ActionScript code, we refer to this simply as dt). This small time increment will correspond to one redrawing of the display. The discretized equations for motion can be obtained from the Lorenz equations using the approximation Δx = (dx/dt)Δt, and similar for y and z:

Δx = [a(y-x)]Δt,
   Δy = [x(b – z) – z]Δt,
   Δz = [xy – cz]Δt.

These are the equations we use to describe the motion of the "bubble emitter" through space in our Flash application. The emitter is positioned at an intial position, and the changes in its coordinates over time are given by Δx, Δy, and Δz. Since we are drawing only a two-dimensional trail of bubbles, we use only the x and z coordinates for positioning, which can be thought of as projecting the three-dimensional trajectory onto the xz-plane.

The character of this trajectory over time is greatly influenced by the choice of constants a, b, and c. The particular choices a=10, b=28, c=8/3 which are used here produce a trajectory which can be said to follow a "strange attractor." Roughly speaking, this means that although the trajectory is completely deterministic, it seems to be subject to random and abrupt changes that follow no observable pattern.

Back to Advanced Tutorials              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. Click the Contact Us link below and email one of us.

Adobe®, Flash®, ActionScript®, Flex® are registered trademarks of Adobe Systems Incorporated.