Janet Helmstedt

In this article we demonstrate a method of constructing various types of graphics from polygonal arcs using replacement rules for vertices. The article is based on a presentation entitled “Constructing Graphics from Polygonal Arcs Using Replacement Rules for Vertices” given by the author at the Wolfram Technology Conference in Champaign, Illinois in October 2006.

Introduction

The simplest type of Lindenmeyer or -system can be used to construct graphics as follows. Two polygonal arcs A1 and A2 are chosen, such that the length of each line segment is an integral multiple of a fixed positive number, , and if a line segment has length , then it is treated as a polygonal arc consisting of line segments of equal length. Also, the angle between each pair of adjacent line segments is an integral multiple of a fixed angle, . A1 is usually chosen as a single line segment or as the boundary of a regular polygon. Each line segment of A1 is replaced by a copy of A2, and then each line segment of the resulting polygonal arc is replaced by a copy of A2, and so on. The constructions are achieved by interpreting certain replacement rules for sequences as replacement rules for line segments [1].

We present a different method of constructing graphics of the above type that has the advantage that there are no restrictions on the lengths of the line segments of A1 and A2, nor on the angles between adjacent line segments. Also, different replacement rules may be applied to the different line segments of A1, and the code used is straightforward.

More complicated forms of -systems can be used to construct space-filling curves and plant-like forms [1]. The method described in this article does not lend itself to such constructions. Applications of even more complicated forms of -systems called parametric -systems, which place no restrictions on lengths or angles of polygonal arcs, can be found in [2].

We make simple changes to the given programs in order to generate other interesting graphics.

A Method of Constructing a Polygonal Arc

A polygonal arc is a segmented line connecting a finite sequence of points in the plane. The line may intersect itself and segments of the line may be repeated. The programs described here are based on a method of constructing a polygonal arc with initial point the origin.

A point in the plane at a distance from the origin can be represented by a complex number of the form , real, .

A second point at a distance from can be represented by a complex number of the form , and so on.

To construct a polygonal arc, , with vertices represented by the sequence of complex numbers , we apply operations on lists to the sequence .

We then calculate the coordinates of the points and join them in order with Line or ListPlot. With this method of construction, the polygonal arc is determined by the sequence .

We can then apply replacement rules to the sequence , and hence to itself.

For example, we construct the polygonal arc with initial point the origin and other vertices determined by the sequence , where and are arbitrary.

Applying Replacement Rules to a Line Segment

Consider the function rA.

The sequence determines a polygonal arc consisting of a single line segment, , starting at the origin. The list inside rA determines a replacement rule for .

The resulting arc, , is called the initial arc. We apply a nesting process in rA, choose values for and , and interpret the resulting sequence as a polygonal arc. The nesting process replaces by a (possibly scaled) copy of , and then each segment of by a copy of itself, and so on. The function arcRep can be used to apply the replacement rule determined by r repeatedly to a line segment. Also opts can be used to determine a graphics option if needed.

If the zero in the definition (the second argument of FoldList) is replaced by , the starting point of the arc becomes .

Here rA is nested four times.

Notice that the above graphic is covered by seven (approximately) similar copies of itself. In the first three graphics, as can be seen from the axes, the larger the number of iterations, the larger the graphic in real terms. From now on, except in one case, we omit axes.

Here .

In the rest of this article, we will construct a dozen or so variations of the function rA by changing the list involving and . To automate this, we define the function defineRule. Its first argument is the function name (like rA) and its second argument is a list.

In the following example, we use a nonsymmetric rewriting rule.

As before with rA, this recovers the list.

We remark that the entry in the replacement rule rB has the effect of doubling angles.

Here .

In the case , there is no rotation.

A polygonal arc constructed by the above method may be rotated, scaled, and in some cases, reflected, using variations of its defining replacement rule.

A reflection will not be obtained unless the entries in the replacement rule are all real. However, in such a case, a different replacement rule may be constructed to effect a reflection.

Applying Replacement Rules to the Segments of a Polygonal Arc

We use Join to concatenate a list of replacement rules and so concatenate the resulting polygonal arcs. The function arcJoin defined here can be used to construct a sequence of concatenated polygonal arcs when x is replaced by a sequence of replacement rules.

In the following example, we apply a replacement rule to the edges of a right isosceles triangle.

Here .

In the following example, we apply a replacement rule to each side of a line segment.

Here .

In the following example, we apply a replacement rule to each side of the edges of a square.

We apply the replacement rules rG and alternately to the edges of a square.

Here .

In the following example, we alternate rH with four and with three iterations.

In the following example, and we alternate -rH with four and rH with three iterations.

The following example illustrates the use of Reverse to obtain a symmetric image from a nonsymmetric replacement rule.

Here is a variation.

Interesting graphics may sometimes be constructed using replacement rules of the following type.

The function defineRule only works with lists, so for rJ we go back to the style of definition used for rA.

In spite of the result for , the replacement rule rJ1 does not generate the above graphic.

A variation.

Replacement Rules with Constant Entries

A rewriting system may contain constant entries, which are not affected by iterations. This means that one or more of the line segments of the initial arc remain unchanged after iteration.

This sometimes gives a tiling of the plane.

Here is a variation.

Plot Variations

Applying Polygon to a List of Vertices

The polygonal arcs constructed by the above method do not always form the boundary of a polygon. However, interesting graphics may sometimes be obtained by applying Polygon to the list of vertices. The function poly defined below can be used to construct such a graphic.

In this example, Polygon is applied to the vertices of an arc that is neither closed nor symmetrical.

Here is a variation.

The entries in our very first replacement rule rA are not all real.

Define rA1 by replacing I by .

The replacement rule may be used to generate polygonal arcs that are reflections of those generated by rA and similarly for rA1 and .

We illustrate by means of the following example, in which we apply the replacement rule to two sides and rA to the third side of an equilateral triangle.

Here is a variation.

In the following example, we apply the replacement rule rA1 to the sides of a regular hexagon.

Here is a variation.

References

[1] M. Trott, The Mathematica GuideBook for Graphics, New York: Springer-Verlag, 2004.
[2] P. Prusinkiewicz and A. Lindenmayer, The Algorithmic Beauty of Plants, New York: Springer-Verlag, 1990.
J. Helmstedt, “A New Method of Constructing Fractals and Other Graphics,” The Mathematica Journal, 2011. dx.doi.org/doi:10.3888/tmj.13-4.

About the Author

Janet Helmstedt was a lecturer in the Department of Mathematics of the University of the Witwatersrand, Johannesburg, South Africa. She is coauthor with Chonat Getz of the book Graphics with Mathematica: Fractals, Julia Sets, Patterns and Natural Forms.

Janet Helmstedt
30 Meyer Street
Oaklands
Johannesburg, 2192, South Africa

janetfractal@hotmail.com