Rendering the Lorenz Attractor

Articles —> Rendering the Lorenz Attractor

In a previous article I outlined how one can program the Lorenz Attractor. While programming the Lorenz Attractor is a fun exercise, it is typically not complete without visualization.

Recall the Lorenz Attractor iteratively calculates points in three dimensional space. These generated points gives a framework by which we can plot the attractor. For instance, in two dimensions one can ignore any one particular axis, assigning the remaining axis values of the Lorenz Attractor coordinates to the x and y axis of a two dimensional image. Alternatively, one can utilize all three dimensions of the Lorenz Attractor coordinates to visualize the attractor using a three-dimensional engine of choice.

  • Two dimensions

    One can render a final image of the Lorenz attractor after several iterations, or animate its creation by updating an image after every iteration. Below is an example in javascript which performs the latter (animation), using an SVG element to draw two dimensional spheres representing the attractor coordinates, updating the image every 30 milliseconds (see page source for code):

    SVG element displaying the animation of the Lorenz Attractor using javascript animation. View looking down the y-axis, with x on the horizontal and z on the vertical.

  • Three Dimensions

    A more complex method to render the Lorenz Attractor is to rely on a three dimensional rendering engine. In the images and videos that follow, I used OpenGL and Java (JOGL) to render the Lorenz Attractor*. Two examples are shown below, both of which render the coordinates of the attractor as sphere's in OpenGL (using JOGL and glutSloidSphere). In both instances, custom coloring was created based upon distances between one coordinate and the coordinate of the previous iteration (green being near, red being far).

    The first example is an image of the Lorenz Attractor after several iterations, in which the attractor from this perspective takes on the appearance of an infinity sign:

    lorenz attractor infinity

    The Lorenz Attractor rendered in OpenGL.

    This second example is a movie which animates the creation of the Lorenz Attractor. A sphere is faded in at each iteration, and the view transformation is changed several times to give different perspectives of the attractor. In some cases, the spline curve created by the coordinates of the attractor was used for the viewing transformation, giving the first person 'roller coaster' perspective in parts of the video. The animation was put together from individual images using ffmpeg to stitch the movie together, using the music of Bach's Prelude in C, kindly provided by Kevin McLoed (Creative Commons).

*Code available by request



There are no comments on this article.

Back to Articles


© 2008-2022 Greg Cope