Mathematical Hints for Parameter Selection for AA Patterns
Year: 2011 Authors: Abdalla G. M. Ahmed
Core claim
Continued-fraction structure of α can be used to predict and tune AA Pattern repetition, clustering, and crossbreeding behavior.
Topics
algorithmic art, continued fractions, parameter selection, pattern repetition, quantization artifacts
Domains
affine transformations, Pell equation, number theory, continued fractions, algorithmic art, visual pattern design, generative graphics, visualization
Methods
elementary algebra, continued-fraction analysis, rational approximation, pattern crossbreeding
Media
pixel patterns, Java applet, colored figures
Paper text
The text below is the locally extracted OCR/Markdown version of the paper. Raw PDF files remain local and are not published here.
Bridges 2011: Mathematics, Music, Art, Architecture, Culture
Mathematical Hints for Parameter Selection for AA Patterns
Abdalla G. M. Ahmed Email: abdalla_gafar@hotmail.com
Abstract
“AA Patterns” is the collective name of a recently introduced algorithmic art, where a simple affine 2D transformation is employed to generate aesthetic patterns. AA Patterns are controlled by a single real parameter between 1 and 2. This paper presents examples of how mathematical analysis can help in selecting and tuning the pattern parameter in such a way as to attain certain features in the generated pattern.
1 Introduction
“AA Patterns” is the name of a new algorithmic art comprising symmetric pixel patterns generated from a simple affine 2D transformation with one parameter. AA Patterns were first introduced in [2], along with detailed technical analysis and some generation and coloring algorithms. In Section 2 we briefly provide the reader with essential background about these patterns, then we discuss in subsequent sections some ideas for the objective selection of the parameter, and we show how certain structures of real numbers manifest in AA Patterns.
2 AA Patterns Overview
Consider the transformation
\left[ \begin{array}{l} X \\ Y \end{array} \right] = \left\lfloor \frac {1}{2} \left[ \begin{array}{cc} \alpha & - 1 \\ 1 & \alpha \end{array} \right] \left[ \begin{array}{l} x \\ y \end{array} \right] \right\rfloor \quad 1 < \alpha < 2, \tag {1}which maps integer points in a source plane to the corresponding integer points in a target plane, using the floor function to quantize real numbers to integers. There are target points to which no source points map, and the set of all these target points is called an AA Pattern. Any real number between 1 and 2 is associated with a unique AA Pattern, designated as .
Figure 1 shows example AA Patterns. Notice how the points that make these patterns tend to group in symmetric clusters. We will elaborate on this observation further, so let us define some terms to describe AA Patterns:
Levels: The constituent clusters of an AA Pattern come in varying levels of complexity, as in Figure 2. We will use the term ‘level n’ to mean both the nth level of complexity, and the clusters at that level. In all AA Patterns, Level 1, the simplest, is made of either isolated points, or grids of points.
There are also some points which do not belong to a specific cluster. Instead, these points fill the pattern outside the various clusters. We have colored different levels in different colors throughout the illustrations in this paper.
Density: The patterns in Figure 1(b), and in Figure 2, have identical clusters at levels 1 and 2. Notice, however, that is crowded with level 2 clusters, in contrast to the sparse appearance of these clusters in . We say that level 2 is denser in than in . In section 4 we will see an example of how the density of levels relate to the parameter .
Ahmed
(a)
(b)
(c)
Figure 1: Example AA Patterns: (a) , (b) , and (c) ; colored to reveal details. Notice how points tend to group in symmetric clusters, and notice the apparent gaps between the clusters.
(a)
(b)
Figure 2: (a) is built from 3 distinct types of clusters (b), at varying levels of complexity. The smallest tile of this pattern contains 25 level 1 clusters of 1 point each, 25 level 2 clusters of 12 points each, 1 level 3 cluster of 336 points, and 860 unclustered points. Notice how each level 3 cluster has pockets for housing 9 level 1 clusters and 4 level 2 clusters.
The natural question about AA Patterns is how to select the parameter . Indeed, there is an infinitude of real numbers between 1 and 2, and it is desirable to have a way to know which values of will generate patterns with some specific set of features. In the rest of this paper we will demonstrate how mathematical analysis could help in achieving this goal.
3 Square Roots
It was shown in [2] that an irrational parameter generates an aperiodic AA Pattern, whereas a rational parameter , , generates a periodic pattern , with translational symmetries over the steps
Even when is only a close approximation to , then the pattern tends to repeat, with small discrepancies, over the same steps as in (2). They are these discrepancies that distinguish AA Patterns from simple tiling patterns.
Thus, the best rational approximations of manifest in the distances between repeating details in the pattern, and if we have a method to understand or control the distribution of the best rational approximations of , then that method will help us predict or control the associated pattern. Continued fractions offer this sought after method, and square roots offer good template parameters to start with. Indeed, square roots (and all quadratic irrationals) have periodic continued fraction expansions, and hence have regular distributions of best rational approximations. Let us make a quick review of this. Let be a non-square integer, and let
(3)
The closest can come to is when
(4)
This is the Pell equation [3]. Now suppose that another pair of integers also satisfies equation (4), and that is linearly related to :
[ \left[\begin{array}[]{c}p\prime\ q\prime\end{array}\right]=\left[\begin{array}[]{cc}a&b\ c&d\end{array}\right]\left[\begin{array}[]{c}p\ q\end{array}\right]\quad a,b,c,d\in\mathbb{Z},. ] (5)
Substituting and from (5) into (4):
or
(6)
Comparing (6) to (4) we get:
(7) (8) (9)
From these three equations we can see that and . It remains, then, to solve (7) which is, again, Pell’s equation. It is known to have a solution for all in the positive case, hence it is always possible to find linearly related best rational approximations of square roots that satisfy (4). But we are not solving for ! We are actually interested in and . Indeed, a bit of algebra shows that the set of pairs that solve equation (4) forms the sequences
(10) (11)
for which
(12)
If the limiting ratio in (12) is too large, the best rational approximations of are too far apart, so are the partial-repetition steps of the pattern. We should therefore search for relatively small values of and . One way to do so is to set and then find for different values of . Thus, (7) should be re-arranged to read
(13)
When is 1, (13) solves to
(14)
for the minus case, and
(15)
for the plus case. Square roots of these are all candidate template parameters to start from, after applying the suitable integer offset that brings back into the the range , as required in the transform (1). Experimentation revealed that the group of patterns , and the group , constitute two families of AA Patterns characterized by common features. We will call these two families of patterns the and the families, respectively.
Figure 3 shows example and patterns. Let us take as a reference, and make a short description of it. Each cluster in looks like a tilted ‘#’, with two arms in each of the East-of-North, South-of-East, West-of-South, and North-of-West directions. Each cluster is surrounded by a ring of 12 clusters from the lower level, and each cluster houses one cluster from the lower level in the middle, and houses 16 clusters from the next lower level, and many more from each of the lower levels. These relationships are recursive. For example, each of the surrounding clusters has its own suite from the lower levels. More important, there is an apparent self-similarity between levels, and each level looks like being synthesized from parts of the lower level.
The other patterns are similar to , but have increasing densities at all levels. For example, the single lower-level cluster in the middle becomes a grid of clusters, the two arms become many arms, and the surrounding ring becomes a band of rings. The corresponding patterns from the and families have the same general features, but the latters have longer arms than the formers, as can be seen in Figure 3.
The metrics (the distances between repeating details) in and patterns reflect sequences obtained from (10) and (11). For example, the metrics of manifest the sequences and (seq. A001353 and A001835 in [5]). A unique property of is that and the limits in (12) are related to the trigonometry of multiples of , and for this reason the pattern also exhibits a sort of rotational symmetry around this angle which divides the circle uniformly.
4 Continued Fractions
In the previous section we have selected square roots of two sets of integers as template parameters for AA Patterns, and in this section we will illustrate how to tweak these initial parameters in order to control the patterns. For this purpose we will investigate the continued fraction expansions of our template parameters. We will write continued fractions in the form
Further, we will use curly brackets to enclose a portion of the continued fraction that repeats zero or more times, or possibly repeats forever if it is the last entry.
Equations (10) and (11) describe the convergents of the parameter , in terms of the two preceding convergents. In this form, the equations essentially tell that subsequent entries of the continued fraction expansion of are equal:
(16)
but the parameters use subtraction in their continued fraction, like
Mathematical Hints for Parameter Selection for AA Patterns
(a)
(b)
(c)
Figure 3: (a) and (b) are the first patterns in the and families, respectively, and (c) and (d) are the seconds. Notice how the family of patterns have longer arms than the family, and notice that the second pattern in each family is denser than the first, at all levels, and that its clusters has one more arm in each side.
(d)
Ahmed
(a)
(b)
(c)
Figure 4: (a) , (b) , and (c) , showing how a new higher level appears on adding a new period to the continued fractions expansion of compliant to (17) and (18).
When the appropriate offsets are included, and if we restrict ourselves to addition only in continued fractions, we find that the parameters of patterns have the periodic form
and the parameters of patterns maintain the periodic form
Let us now try some tweaks on our template parameters. The reader is also encouraged to experiment himself using the interactive Java applet which the author has made available online [1].
Truncated Patterns: The first tweak that might come into mind is to truncate the infinite continued fraction of the irrational at some period. It was found that truncating the continued fraction to few periods limited the constituent clusters of the pattern to few levels. Seen the other way round, each additional period in the continued fraction corresponds to a new level in the pattern, as illustrated in Figure 4. We will use patterns truncation in our subsequent examples to limit the patterns to level 4, which should be sufficient for the illustrations.
Intra-Family Hybrids: Instead of exactly repeating the periodic entries of the continued fraction, a possible tweak is to borrow one or more periods from the parameters of other members in the same family of patterns. The borrowed periods bring features from their source patterns, as illustrated in Figure 5. Another way to look at this tweak is that we modify the value of at certain periods. Seen this way, we find that the value of at different periods control the density of levels. It is subtle, however, to notice that the level whose density is affected is not the level associated with the modified period (in terms of truncation discussed above), but the lower level.
Inter-Family Hybrids: Crossbreeding the and families is also possible. It took some experimentation to find out how to switch between the continued fraction forms (17) and (18). For an AA Pattern to start like patterns, and then switch to look like patterns at higher levels, the parameter should have the form
and for a pattern to start like patterns, and then switch to look like patterns at higher levels, the parameter should have the form
Mathematical Hints for Parameter Selection for AA Patterns
(a)
(b)
(c)
Figure 5: (a) , (b) , and (c) , showing the effect of replacing the first, second, or third period, of (truncated) with the corresponding periods from . Compare with the original patterns in Figure 1(a, c).
(a)
(b)
Figure 6: (a) looks like patterns (short arms) at level 2, and like patterns (long arms) at level 3. In contrast, (b) looks like at level 2, then switches to look like at level 3. Level 1 has the same look in and patterns.
(a)
Figure 7: Example dual-parameters patterns: (a) AA ([1; 1, 2, 1, 2, 1, 2, 1], [1; 1, 4, 1, 2, 1, 2, 1]), and (b) AA ([1; 1, 2, 1, 2, 1, 2, 1], [1; 1, 3, 4, 4]).
(b)
Figure 6 illustrates these tweaks. It is possible to switch back and force between the two families as many times as wished.
Dual-Parameters Patterns: There is a completely different approach to crossbreeding in AA Patterns: to use different values of in the two entries of (1). Not all AA Patterns can mix this way, but at least all members of and families (and their truncated, intra-family, and inter-family derivatives) can mix smoothly. The resulting patterns reflect one of the mixed patterns in one direction, and the other parent pattern in the orthogonal direction. Dual-parameters patterns can be designated as . Figure 7 shows some examples.
5 Conclusion
We have seen that the AA Patterns are controllable in many ways by manipulating the continued fraction of . Only two forms of continued fractions were investigated, and we have found that it is possible to tweak these forms as needed. Other forms of continued fractions should be the subject of future research.
What we have discussed could be approached differently as a way to predict AA Patterns. Indeed, if the continued fraction of could be parsed successfully into the form:
or in the continued fraction form:
then it is possible for a person, or even a computer, to tell how the resulting pattern would look. This suggests a role for AA Patterns in visualization.
It is worth noting that AA Patterns are closely related to Voronoi patterns discovered accidentally by Kaplan [4], since both types involve quantization artifacts. Many differences make research on AA Patterns easier than Voronoi patterns. After all, the logic of AA Patterns is completely contained inside the generating algorithm, and the algorithm is simple and linear. The argument remains, however, that such accidentally discovered algorithmic arts are worth the research.
Moreover, Kaplan resorted to frequency domain in his analysis, whereas all the analysis of AA Patterns, herein or in [2], used elementary algebra. Thus, there is a potential of making new findings, either in AA Patterns or in Voronoi patterns, by exchanging the analysis approaches. Experimenting with either types of patterns remains a good starting point for making new findings like the ones discussed here, and for that reason the reader is encouraged to experiment with the Java applet the author has made available online [1].
References
- [1] Abdalla G. M. Ahmed. AA Patterns Web Site. http://aapatterns.abdallagafar.com.
- [2] Abdalla G. M. Ahmed. Pixel Patterns from Quantization Artifacts of Forward Affine Mapping. Journal of Graphics, GPU, and Game Tools, 15(2):73–94, 2011. DOI: 10.1080/2151237X.2011.563670.
- [3] H. W. Lenstra Jr. Solving the Pell Equation. Notices of The American Mathematical Society, 49 Number 2:182–192, 2002.
- [4] Craig S. Kaplan. Aliasing Artifacts and Accidental Algorithmic Art. In Renaissance Banff: Bridges 2005: Mathematical Connections in Art, Music and Science, pages 349–356, 2005.
- [5] Neil A. J. Sloane. The On-Line Encyclopedia of Integer Sequences. Accessible electronically at http://www.research.att.com/~njas/sequences/ or at http://www.oeis.org.