DEV Community

Rat Wolf (ratwolf)
Rat Wolf (ratwolf)

Posted on • Edited on

An old Classic with new Perspective in 2D and 3D

Historical Context

The Hopalong* attractor, authored by Barry Martin of Aston University in Birmingham, England [2], was popularized by A.K. Dewdney in the September 1986 issue of Scientific American. In Germany, the Hopalong attractor gained further popularity through an algorithm called HÜPFER in the article Psychotapeten published in Spektrum der Wissenschaft. [3].

*Nicknamed by A.K. Dewdney.

Python Code, detailed description and mathematics see:

GitHub

The Hopalong Attractor Functions

The mathematical definition of the Hopalong attractor is given by the following system of recursive functions, defined in [2]:

Hopalong

Where:

  • The sequence starts from the initial point (x0 , y0) = (0 , 0).
  • xn and yn represent the coordinates at the n-th iteration of the attractor.
  • a, b, and c are parameters influencing the attractor's dynamics.
  • sgn is the signum function. However, the programs use math.copysign(), which is defined as follows:

Copysign

Computational Approach

The available Python programs calculate and visualize the attractor by iterating the described function system.

Goal:

  • Visual Representation:
    The attractor is rendered as a density heatmap, with color intensity reflecting areas of high or low point concentration.

  • Efficiency:

    • Large numbers of iterations are computed with low memory usage and high processing speed.
    • Just-in-time (JIT) compilation is applied and supported by a low-complexity code structure.

Core Algorithm:

The algorithm consists of two main passes:

  • First Pass: Determines the spatial extent of the attractor trajectory.

  • Second Pass: Maps the sequentially generated trajectory points in continuous space directly to a discrete pixel grid, keeping track of the number of pixel hits used to generate the density heatmap matrix.

Hopalong Attractor 2D

Hopalong Attractor 3D

References

[1] J. Lansdown and R. A. Earnshaw (eds.), Computers in Art, Design and Animation. New York: Springer-Verlag, 1989.
e-ISBN-13: 978-1-4612-4538-4.

[2] Barry Martin, "Graphic Potential of Recursive Functions," in Computers in Art, Design and Animation [1], pp. 109–129.

[3] A.K. Dewdney, Psychotapeten, algorithm HÜPFER, in Spektrum der Wissenschaft: Computer Kurzweil.
Spektrum der Wissenschaft Verlagsgesellschaft mbH & Co., Heidelberg, 1988.
(German version of Scientific American).
ISBN-10: 3922508502, ISBN-13: 978-3922508502.

Top comments (0)