Tutorial: Generalized de Jong Coloring

Text and Images © 2011 Kerry Mitchell

Introduction

This coloring is based on an attractor developed by Peter de Jong. His attractor is based on iterating sinusoidal functions:

xn+1 = sin(a × yn) - cos(b × xn),
yn+1 = sin(c × xn) - cos(d × yn).

My generalization expands the type of function and their inputs.

Background

De Jong simply used the previous x and y values (scaled by frequencies a, b, c, and d) as inputs. I've extended that notion to also allow a general linear or quadratic function of x and y as the stuff inside the parentheses: For the stuff outside of the parentheses, de Jong used the standard (circular) sine and cosine functions. The bane of many a trigonometry student, these functions turn out to be horribly useful for a variety of reasons. Professionals often refer to these as the circular trigonometric functions, in reference to their relationship to the coordinates of points on a circle. For a circle of radius 1 whose center is at the origin (point (0, 0)), the x- and y-coordinates of a point are given by: x = cos(θ) and y = sin(θ), where θ is the angle from the +x axis (measured counter-clockwise positive). Unwrapping these relationships and plotting both functions against the angle θ, you can easily see that both are periodic (that is, they repeat infinitely) with a period of 2π radians, and they are both bounded between -1 and 1. These characteristics make them ideal for this algorithm.


Unit circle and circular cosine & sine functions

When I first learned of these functions and their relationships to the circle, it seemed to me that their graphs should be circular. That is, if you plotted a full period of either, you should get four quarter-circles. That clearly isn't the case (and for good reasons), but that thought does invite investigation into other (probably less useful) functions. I call the first variation available in this formula the "superellipse" version. That's because plotting it gives four quarter superellipses--ellipses whose power is not necessarily 2. The graph below shows the superellipse version of the sine function for powers of 0.5, 1, and 2. In the coloring, you can choose any value from 0 on up.


Superellipse sine functions

The circular sine and cosine functions give the x- and y-coordinates of points on a circle (respectively). With a bit of effort, one can generate formulas for the coordinates of points on other shapes. My second variation, "polygonal," does that for regular polygons. As the number of sides increases, a regular polygon increasingly approaches a circle. In a similar fashion, the polygonal sine and cosine functions become indistinguishable from their circular counterparts as the number of sides increases. Conversely, the greatest differences between the two functions occur when the number of sides is the least, 3. The graph below shows the polygonal sine function for 3, 5, and 8 sides. In the coloring, you can specify at least 3 sides.


Polygonal sine functions

Parameters

The parameters are in three groups: general parameters, those for the functions (x-cosine, x-sine, y-cosine, and y-sine), and drawing parameters.

General parameters

x-cosine function

These parameters are repeated for the x-sine, y-cosine, and y-sine functions. Which specific parameters are shown depends on the modes chosen.

Drawing parameters

Hints

You are, of course, free to use this coloring however you’d like. However, these hints may help your explorations be more productive.

Sample Images

Click the image to see its parameters.


Sample 1.
This image uses the de Jong mode and the standard trig functions.


Sample 2.
This image uses the linear mode and the superellipse trig functions.


Sample 3.
This image uses the quadratic mode and the polygonal trig functions.

Enjoy!

Back to Tutorials page
Up to my home page