Attractors and repellers of Koch curves

Przemyslaw Prusinkiewicz and Glen Sandness Abstract

This paper presents two methods for generating Koch curves, analogous to the commonly used iterative methods for producing images of Julia sets. The attractive method is based on a characterization of Koch curves as the smallest nonempty sets closed with respect to a union of similarities on the plane. This characterization was first studied by Hutchinson. The repelling method is in principle dual to the attractive one, but involves a nontrivial problem of selecting the appropriate transformation to be applied at each iteration step. Both methods are illustrated with a number of computer−generated images. The mathematical presentation emphasizes the relationship between Koch construction and formal languages theory. Reference

P. Prusinkiewicz and G. Sandness: and repellers of Koch curves. Proceedings of Graphics Interface '88, pp. 217−228. ATTRACTORS AND REPELLERS OF KOCH CURVES

PrzemyslawPrusinkiewicz and Glen Sandness

Departmentof ComputerScience University of Regina Regina, Saskatchewan,Canada S4S OA2

ABSTRACT struction consists of recursively replacing edges of an This paper presents two methods for generating Koch arbitrary polygon (called the initiator) by an open polygon curves, analogousto the commonly used iterative methods (the generator), reduced and displaced so as to have the for producing images of Julia sets. The attractive methodis same end points as those of the interval being replaced. basedon a characterizationof Koch curves as the smallest (The original construction [Koch 1905] was limited to the nonemptysets closed with respect to a union of similarities definition of the now famous "snowflake" curve.) As pointed on the plane. This characterizationwas first studied by out by A.R. Smith [1984], this is a language-theoretic Hutchinson. The repelling method is in principle dual to the approach: the is generated by a rewriting system (a attractiveone, but involves a nontrivial problem of selecting "granunar") defined in the domain of geometric shapes. In the appropriatetransformation to be applied at eachiteration contrast, the method of function iteration refers to notions of step. Both methods are illustrated with a number of complex analysis. The main idea is to analyze sequences of computer-generatedimages. The mathematicalpresentation numbers {xn} generated by the formula Xlttl = /{xn>, wheref emphasizesthe relationship betweenKoch constructionand is a complex function. The fractal, called a , is a set formal languagestheory. invariant with respect to f. Sequences of points originating outside the fractal may gradually approach it - in which RESUME case the Julia set is said to be an of the process f - Dans cet article nous presentonsdeux methodespour pro- or they may diverge from the fractal, and the set is then duire des images des courbes de Koch. La methode par called a repeller of f. A discussion of fractal generation attirance est fondee sur une etude des ensemblesautosimi- techniques using attractive and repelling processes was laires inauguree par Hutchinson. Une courbe de Koch est presented, among others, by Peitgen and Richter [1986]. considereecomme Ie plus petit ensemblenon-vide fenne par rapport a l'union des sirnilarites dans la plaine. La methode According to the above descriptions, the methods for par repulsion est une reciproquea la methodepar attirance. generating Koch curves and Julia sets appear totally unre- On observe alors une analogie avec les methodes a lated to each other. But is this the case indeed? From the engendrerdes ensemblesde Julia qui, elles aussi, peuvent theoretical point of view, an answer to this question was etre soit attirantes, soit repoussantes.Les deux methodes given by Hutchinson [1981]. He studied sets closed under a sont iIlustrees par plusieurs images produites a l'aide de union of contraction maps on the plane (specifically, similar- l'ordinnateur. La presentation mathematique se sert d'un ities), showed their fractal character, proved that they can be lien entre la constructionde Koch et la theorie des langages considered as attractors, and indicated the relationship fonnels. between these sets and Koch curves. Our paper applies Hutchinson's theory to computer graphics. We present two algorithms for generating images of Koch curves. The KEYWORDS: fractal, attractor, repeller, Koch construc- attractive method is similar to a method for generating tion, rewriting system, iterative function system, dynamic images of Julia sets termed the inverse iteration method process. (JIM) by Peitgen and Richter [1986]. An image is obtained by plotting consecutive points attracted by the fractal. This method is relatively fast and particularly useful when study- 1. INTRODUCTION ing the impact of parameter changes on the curve shapes. In recent years the beauty of has attractedwide Numerical parameter modifications make it easy to generate interest among mathematicians, computer scientists and new variants of known curves. Continuous parameter artists. A number of techniquesfor generatingfractal shapes changes allow for animating transformations of Koch curves were developed and used to produce fascinating images. in a way similar to the transformations of Julia sets [Norton Two techniques,popularized by Mandelbrot's book [1982], 1986]. On the other hand, the repelling method makes it have gained a particular popularity. These are the Koch possible to obtain colorful images of the entire plane con- construction,and function iteration in the complex domain. taining a Koch curve. This method is analogous to the According to Mandelbrot's generalization, the Koch con- method for creating colorful images of Julia sets. However,

Graphics Interface '88 in the case of Koch curves a specific new problem occurs. a plane. We write: A = {a-v . . . .~}, or A = ift . . . a-n in The~ are a number of similarities involved in the iteration short. Given the plane, we denoteby W and W* the set of process, and only one should be applied at each iteration all vectorsand the classof all polyvectors,respectively. step. The problem is to select the correct transformation. Definition 2.2. A Koch systemis a pair K = < I, P > where Our paper extends Hutchinson's results in three direc- I = 0'1. . . ~ E W* is called the axiom or initiator, and tions: P = (~ ql... qm) E WxW* is called the production. To . We analyze the relationship betweenKoch construction specify a production, we use the notation P'-t ql . . . qm. and iteration of similarities in a formal way, basedon a The vector P' is called the predecessorof productionP, and definition of the Koch construction in terms of formal the polyvector ql... qm is called the successoror genera- languagestheory. Our analysis is not restricted to the tor. limit Koch curves,but also includes their finite approxi- Remark 2.1. Definition 2.2 extends Mandelbrot's [1982] mations. descriptionof the Koch constructionin threedirections: . In addition to the attractive algorithm for generating The basic elementsof the constructionare vectors,not images of Koch curves, which is a straightforward . line segments. consequenceof Hutchinson's paper, we introduce a The initiator and the production successor are arbitrary repelling algorithm. . . We illustrate both algorithms on a number of examples sets of vectors.They need not be of equallength, form a polygon or even be connected. using computer-generatedimages. . The predecessorof the production is an arbitrary vec- The paper is organized in the following manner. Sec- tor. It neednot be connectedto the successor. tion 2 presentsa fonnal definition of the Koch construction The aboveextensions have the following justification: expressedin terms of formal languagestheory. Section 3 shows the equivalencebetween the Koch construction and . Vector orientation plays an essential role in the Koch iteration of a set of similarities on the plane. The discussion construction. Two Koch systemswhich differ only by is limited here to curves which can be constructedin a finite the orientationof vectors in the initiator and/orproduc- number of steps. An extension to infinite-order curves is tion may generate totally different fractals. Thus, a p~sented in Sections4 and 5. Section 4 recalls the standard definition of a Koch systemwhich makesno reference notion of the topological limit of a sequenceof sets. Section to line orientationis incomplete. 5 applies this notion to define limit Koch curves, and pro- . When describingthe constructionof somefractals - for vides their algebraiccharacterization. Section 6 presentsthe examplethe dragoncurve and the Gospercurve - Man- correspondingmethod for generatingapproximations of limit delbrot complementsthe specificationof the initiator Koch curves, with examples of fractal images. Section 7 and the generatorwith additional rules of application. introducesa dual descriptionof the limit Koch curveswhich Theserules require the starting point and the end point characterizesthem as repellers rather than attractors. The of the generator to exchange their role in some- resulting method for generating limit Koch curves is also -derivationsteps. By expressingproductions in terms of discussedand illustrated. vectorsinstead of line segmentsit is possibleto incor- porate the rules of applicationinto the formal definition of the Koch system. 2. THE KOCH CONSTRUCTION. . Interesting modifications of fractal shapes can be In order to accuratelystate and prove theoremsrelated obtainedby allowing the vectorsin the generatorto be to the Koch construction, we must substitute a formal of different lengths. definition for its intuitive descriptionusually presentedin the In the following definitions we will refer to the notion literature. A fundamental notion is that of a vector, of direct similarity. A direct similarity is a transformation specified as an ordered pair (x, y) of points in the plane. on the plane which may change the position and size of (Note that throughout this paper, unlessotherwise noted, the symbols x, y, z refer to points rather than coordinates.) geometric figures, but preservestheir shapeand orientation (which can be either clockwise or counterclockwise)as Unless stated otherwise, we operate on fixed vectors, which means that two vectors a'= (xp yJ and b'= (~, Y2) are shown in Fig. 2.1. Such similarity can be expressedas a considered equal if and only if their respective endpoints composition of scaling, rotation and translation; no coincide: xl = X2 and Yl = Y2' (In contrast, free or abstract reflectionsare allowed. vectors are consideredequal if they can be madeto coincide If a transformationT takes figure A to the figure B, we by a translation.)As usual, it is convenientto identify a vec- will write AT = B. tor (a pair of points) with its graphical representation(a line Definition2.3. Let P'-t ql . . . qm be the production of a segmentin the plane). Consequently,we write that a point x belongs to a vector a' if x belongs to the line segment Koch systemK. Consider an arbitrary vector a- and denote representinga'; This convention extends to sets of vectors. by T the direct similarity which takesvector P' to the vec- tor a': pT =£ (Obviously, T is unique.) We will say that Thus, we assumethat point x belongs to a set ~. . . . .P'n} polyvector ~ . . . b'., is directly derived from the vector a- when x belongs to the figure formed as the union of the line and write a'~ ~ . . . b'., iff ~ . . . b'.,= (1i'I . . . qm)T. segmentsof the componentvectors. Definition 2.1. A polyvector is an ordered set of vectors on Remark 2.2. In the caseof rewriting systemswhich operate

GraDhics Interface '88 The next definition extendsthe notion of direct deriva- tion to the predecessorswhich are not single vectors. B U" Definition 2.4. Let Q'I... ~ be a polyvector and -1 "" P'-+ ql . . . ~ the production of a Koch system K. The '" polyvector bll... ~m . . . ~I . . . ~ is directly derived / from the polyvector Q'I... ~ in the system K iff '" ~ =} ~I . . . ~m for all i = 1. . . . ,I. We write: '>C- /"'- ". / a';1 ...a'; I =}b 111m...b ...b 111m....b "-J V A A" Remark 2.4. Note that in the derivation ... .-+.-+"..-+ Triangle A 'B 'C' is related to ABC by a direct similarity a'I ...a'; I =}b 111m...b ...b...bII 1m Triangle A"B"C' is not directly similar to ABC because all vectors ~ (i = 1, . . . ,/) are substitutedby their succes- the mapping of ABC to A"B"C" involves a reflection. sors in a single derivation step. Consequently,Koch sys- tems belong to the class of parallel rewriting systems. In the Fig. 2.1. illustration of the notion of direct similarity. domain of strings, the analogousderivation type character- on strings (for example,context-free grammars), the result of izes L-systems [Lindenmayer 1968, see also Rozenbergand applying a production p -+ ql . . . qm to the letter p is ident- Salomaa1980]. The relationshipbetween Koch systemsand ical with the production's successor: ql'.. qm' Conse- L-systems is quite close: in fact, many Koch curvescan be quently, there is no need for distinguishing betweenproduc- generatedusing L-systemswith a geometricintetpretation of tion p -+ ql . . . qm and the derivationp =) ;J,I. . . qm' In string symbols [Szilard and Quinton 1979, Dekking 1982a contrast,in a Koch system the result ~ . . . bm of applying and 1982b, Prusinkiewicz 1986]. However, a discussionof production P -+ il'J . . ."ltm to a vector 7/ is, in general, the formal aspectsof this relationshipis beyondthe scopeof different from the successorifl . . . ifm (since, in general, this paper. 7/~ P .) Definition 2.5. The notion of the direct derivation is extendedto the derivation of length n ~ 0 in the usual recur- Corollary 2.1. Consider a Koch systemK with production P -+ ifl . . . ifm' and let 7/ -+ ~ . . . ~ be a derivationin K. sive way: Denoteby 9j the direct similarity which takesvector pto the . For any po1yvectorC, C ~o C, vector qj : P9j = qj (j = 1, . . . ,m). In an analogousway, . If Co ~,. C,. and C,. ~ C I then CO~""I C I. denoteby ~ the similarity which takes vector 7/to the vector Definition 2.6. A po1yvectorC,. is the Koch curve of order bj : 7/~j = bj- If T is the similarity which takes vector jj'to n generated by a Koch system K = < I, P > if C,. is derived then ~j rl9jT. a: = in K from the axiom I in a derivationof length n: I ~,. C,.. Proof. According to Definition 2.3, if 7/= jj'T then bj = qj T. Thus,

,,+ 3. FINrrE-ORDER KOCH CURVES. jj'(T~) = c.j = 7/~j = b = qj T = . For any sequenceof indices representeddiagramatically in Fig. 2.2. Note that the map- h,... J,,:j; e{l,... ,m} the following equality holds: pings 9joCPj and R are completely defined by the Koch sys- 'it~. ... ~. = 'it 41. ... 41. tem K, while the mappings~j and T vary from one argument ~I ~. /. JI vector o'to another. where mappings~j and 4Ij are definedas in Corollary 2.1 and --- T --- R --- Remark 2.3. The operation ~j is assumed to be left- a 04D ~O associative: 'it~h". ~j. = (...('it~h) . .. ~j). Proof - by induction on n. . Assuming that the sequenceof zero transformationsis equal to the identity mapping, for n = 0 the thesis is obvious. -- T -- R b --q oc . Assumethe thesis true for an n ? 1 and considera vec- tor '1:'=o'~h . . . ~j.~j~l. According to the inductive Fig. 2.2. Relationship between mappings 9p j.. . . cl>h' Further- points of a fixed vector.) more, from the Corollary 2.1 it follows that the vector The similarities corresponding to the Koch system presented t = a'E.jMIcan be expressed as a'r1ejMIT, where Tis in Fig. 3.1a can be expressed as follows: the direct similarity which takes the production prede- 2 =S(3) R(3) M(3'0) transformation TJ which takes axiom 3' to the vector a'; Consequently, we obtain: 4>J= S(.!.) R(-!:-) M(.!.:!1.) 3 3 2' 6 b'=a'J:. =1Irle. T=1I(TJ-IKI)e. (RTJ)= "JMI JMI JM' jM,TJ= -ucl>jM,cI>j.. . . cl>h 0 Figure 3.1b showsthat a vector I: E C2 can be derived from Interpretation. According to the above theorem, associated the axiom using mappings ~2~' or obtained as the image of with a Koch system K is a set of direct similarities cl>t A the axiom using similarities t The similarities cl>jmust be applied in the Remark 3.1. The specification of similarities 0 is the scaling ratio, curves can be perceived as symmetric patterns which admit . R(a) - rotation by angle a with respect to the origin of similarities as symmetries. The concept of considering simi- the coordinate system, larities as symmetries is certainly not new. The extensive . M(u,v) - translation by vector (u, v). (Note that in this study of "patterns and tilings" by Grllnbaum and Shephard case u and v are coordinates of a free vector, not end- [1987] provides several examples of so-called "similarity patterns" obtained by overlaying smaller and smaller copies of a given motif. However, all these patterns use exactly one similarity. The possibility of generating an abundance of interesting patterns using two or more similarities went unnoticed there. Since each sequence of n similarities , and let denote the union of the similarities =U".

Interpretation. According to the above Corollary, a Koch curve of order n can be obtained recursively, starting from Co= a and using the relation Cj+1= Cj to progress through the sequence of Koch curves of consecutive orders. Cz Note that in general the relation is not monotonic, i.e. Cj is not a superset of Cj. Consequently, the curve Cj+1 cannot be simply obtained by adding new vectors to Cj. Some, if not all, vectors of Ci must also be erased. In the following sections we will introduce the notion Fig. 3.1. a) The production of a Koch system. of a limit Koch curve and we will show that, by operating b) Two methodsfor obtaining a vector b'E Cz on points instead of vectors, it is possible to generate the a sequenceof productionsand a limit Koch curves in a monotonic process with no erasing. sequenceof similarities.

GraDhicg IntArf;lce 'aa 4. THE TOPOLOGICAL LIMIT OF A SEQUENCE OF Definition 5.1. The spread (J of a Koch system K is the SETS. distance between the axiom it and its direct successor c'1 . - . c'm: In this section we recall some basic topological notions accordingto Kuratowski [1972] and Hutchinson[1981]. (J = P(1t,cj . . . c'",) where it~ cj - . - c'm - Let us assumethat all setsconsidered are closedsets on Lemma 5.1. The distance betweentwo consecutivecurves the plane P. Cn and C ! generatedby a Koch systemK with production Definition 4.1. Let p(x,y) denote the Euclidean distance P'-t 7[! . . - 7[m satisfies the the inequality: betweenpoints x,y. The distancebetween point x and set Y length(a'max) is definedas: d--II --< ct- p(x,Y) = inf p(x,y) . length(o') lEY where a'maxis the longest vector in the polyvector CII. The half-distancebetween set X and set Y is equal to: Proof. Consider derivation a'~ ~ . . . ~ which results p'(X,Y) = ~~ p(x,Y) . from the application of productionP' -'t 1fI . . . qm to a vec- tor a'. According to Fig. 2.2, the vectors 12'. ~, . . . ;;-.. arc Note that, in general, p'(X,Y).. p'(Y,x). The distance related to the vectors 0', q, . . . ,cm by a similarity R-IT. betweensets X and Y is the greaterof the two half-distances: hence: p(X,Y) = max {p'(X,Y), p'(Y,x)} . The function p(X,Y) satisfies the distance axioms in the spaceof all closed nonempty subsetsof the plane P and is called the Hausdorff metric on this space. It is easy to notice that for any set families Xv . . . ,xm and Yv . . . 'Yn the following inequality holds: p(C,.,C,..vs ] ~ max {P(XjoYj) : 1S.i~, l~~n} (*) ,.+ ,,+ ,,+ p r~ Xi, C;Yj max {p(aj. bit bj~): ajeC,. & aj~bj, l~1 j=t b.fm} length(itmax) Definition 4.2. A set A such that -v -I:] limp(An.A) = 0 length(O') n-- Definition 5.2. The contraction ratio of a production is called the topological limit of the sequenceof sets p' -7 "if! . . . "ifm is defined as: AO.AI.A2'. . .. It is known that if a topological limit exists, length(q'max) it is unique. Consequently,we can use notation A = Lt An. y= Definition 4.3. Consider a function f P -+ P. The length(Jj') where 7/maxis the longest vector of the generator 7/1 . . . 7/m. Lipschitz constantof / is defined as lip (f) = supp~~)!~» . Lemma 5.2. Assuming the notation of Corollary 2.1 and #y p(x,y) Remark 2.3, the following equality holds: y = max {Lip (9;: lSj~} = max {Lip (4>;: l5J~} We will use the following propertiesof lip (f): . For any points x, yeP =max {Lip (~;: lSj~} . p(f(x), fly» ~ Lip (f) p(x,y) Proof. The equality y = max {Lip (9;: lSjSm} results directly from the Definition 5.2. Furthermore, taking into If f P -+ P and g: P -+ P then . account the property (**) in Section 4, we obtain: Lip (fg) = lip (f) lip (g) Lip (4» =Lip (K"19j R) = Lip (9) . . If / is a similarity then Using the same argument for ~r we conclude that: Lip (f-I) = ~ (**) Lip (9) = Lip (4>; = Lip (~; Lip (f) for any j E {I, . . . ,m}, so the thesis holds. 0 A function/is called a contraction if Lip (f) < 1. Lemma 5.3. The length of any vector "i! in the polyvector Cn satisfies the inequality: '""' 5. THE LIMIT KOCH CURVES. length(b ) S length(o')i' .

This section characterizeslimit Koch curves as sets Proof. According to Theorem 3.1, if b'eC" then thcrc exists a sequcnce of n transformations cl>j,. . . cl>j,such that invariant with respectto unions of similarities. The material of this section is basedon (Hutchinson 1981]. t="itcl>j,...cI>j,. From Lcmrna 5.2 it follows that Lip (cI» ~ y for ~l functions cl>junder consideration.Conse- quently, lcngth(b ) ~ length("it}i'. 0

Graphics Interface '88

~ Definition 5.3. Consider a sequenceof polyvectors C,. gen- p( E: (y}) ~ doY'. Since the set X is assumed to be erated by a Koch system K using derivations of length closed with respect to all transfornlations included in <1>, 0,1,2, A set C- = Lt C,. is called the limit curve gen- y belongs to X. Thus, the half-distance d" = p'( E: X) is eratedby the systemK. less then or equal to doY'. Considering that the con- Theorem 5.1. Consider a Koch system traction ratio y is less then one, the half-distance d" K =< a',P' ~ ql . . . qm>. If the contraction ratio y of the between an arbitrary vector lj' cC" and the set X tends productionP' ~ ql . . . qmis less then 1, then the limit curve to zero when n tends to infinity. Thus, the limit set C- C- exists and is bounded. is a subset of X. Proof. Consider a sequenceC,..C,...v . . . ,Cp of po1yvectors c) Consider an arbitrary point x in the plane, and a point z generatedby the Koch systemK. According to the Lemmas which belongs to C_- Denote by do the distance 5.1 and 5.3, the distancedj betweenconsecutive polyvectors p(x, z). Following the same arguments as in a previous Cj and Cj+1 satisfies the inequality dj ~ 0-1. The distance part of this proof, we obtain: betweenpolyvectors C,. and Cp does not exceedthe sum of P(""'-~'t'J. - - - 4>-/I' z4>.J. - - . 4>-/I) ~ doY' ' distancesd,. + d""l + . . . + dp-1 : where 4>j.. . . 4>j,is an arbitrary sequence of transforma- p-l. ~ p(C,.,Cp)~ }:o'Y = 0"'{' . tions included in <1>". According to part (a), i= 1-)' z4>j. . - . 4>iIE C_, thus p(xj.'.. 4>iI'C_) ~ doY', or Sincey < 1 and p > n, we obtain: p'(x", C_) ~ JoY'. Considering that the contraction 1 ratio y is less then one, the thesis is obtained. 0 p(C",Cp) ~ O"'{'- . 1-)' Corollary 5.1. For any Koch system K with a contraction The aboveformula shows that the distancep(C",Cp) tendsto ratio y < I and any point x in the plane, zero with n-tco, hence according to the Cauchy criterion C- = Lt x" . there exists the limit set C_such that Proof. Following the same argument as in the proof of lim p(C,.,C_)= 0 . ,.-- Theorem 5.2a, we find that the set X = Lt x"has the pro- perty X<1>= X. Thus, according to part (b), C_c X. On the Or, C- = Lt C,.. Furthermore, other hand, from part (c) it follows that X c C_. Thus, 1 X = C_. 0 p(Co.C_)~ (J1=y , Interpretation. Parts (a) and (b) of the Theorem 5.2 so C- is bounded. 0 characterize the limit Koch curve C- as the smallest Theorem 5.2. Consider a Koch system nonempty set invariant with respect to a union of similari- K =< a',P' ~ qj . . . qm >. Th~ contraction ratio y is ties. Part (c) characterizes a set C- as an attractor. The assumedto be less then 1. Let ~ denote the union of the iterative application of the transformations included in <1>can similarities cl>jassociated with K: be considered as a dynamic process [Mandelbrot 1982, Peit- m gen and Richter 1986] which describes evolution of the set II>= U cl>j. of points S" in time. The process starts with a one-element pi set So = {x}. The subsequent sets S" get closer and closer to The limit curve C- generatedby K has the following proper- the limit set C- regardless of the selection of the initial ties: point x: Thus, C- attracts points from the entire plane. a) C_II> = C- , Corollary 5.1 further specifies that all points of C- will by reached by applying some (possibly infinite) sequences of b) For any nonempty set X on the plane, if XII>c X then transformations from <1>to an arbitrary starting point x. C_cX, c) For any point x in the plane limp'(xcI>'" C_) = O. ,.-- 6. THE ATTRACTIVE METHOD FOR KOCH CURVE Proof. GENERATION. a) C- = Lt a"IH-! =( Lt a"= C_ . n--- n-.- n--- Theorem 5.2 and Corollary 5.1 suggest a simple b) Let X be an arbitrary nonempty set closed with respect method for generating finite approximationsof the limit to <1>.In order to show that C_c X we will considera Koch curves. point xeX and a vector b' cCn (n?Q). According to . Start from a set So = {z} where point z is known to the Theorem 3.1, b' is the image of the axiom 0' with belong to C_. respectto some sequenceof transformationsincluded in . Given set S". constructset SlI+l by applying all transfor- j.cI>j_t. . . cl>it. Let y denote the image of x mations $j c j.cI>j_t. . . cl>it, and assume that the distance points approximatingC- is reached. between the axiom 0' and the set {x} is equal to do. According to Lemma 5.2, the distancebetween the vec- Note that all generatedpoints Zt belong to the limit curve tor b' and the set {y} satisfies the inequality C_. so all calculatedpoints contributeto the approximation of C- and no erasingoccurs.

Graphics Interface '88 The above method assumesthat an initial point z e C- a) is known. Two approachescan be used to find such a point. . Solve for z any of the equationsz«Pj = z, where «PjC <1>. Since each mapping «Pjis a contraction,it has a unique fixed point z. Furthermore,z=z«pj for any n ;?;0, thus accordingto the Corollary 5.1, z e C- . . Choosean arbitrary point x in the plane, and apply to it a sequenceof transformations«Ph . . . «Pj.c,the impact of the error in choosing the initial point will further decreaseas the iteration -~~5n~_,.h,,- continues. Fig. 6.1. Two approximationsof the limit snowflakecurve Example 6.1. Figure 6.1 shows two approximationsof one obtainedby the attractivemethod. Approximation(a) branchof the snowflakecurve. The relation <1>used for itera- consistsof 100 points. Approximation(b) has 10,000points. tion is the union of similarities «PI - «P4 from Example3.1. Example 6.4. Figure 6.4 shows the production of a Koch Example 6.2. Plate 6.2 shows four curves generatedby a system generating twig-like shapes [prusinkiewicz 1986]. pair of mappings: The correspondingsimilarities are given below: ." .3" 4>1(Z)= rye'4 2(Z)= rye'7 + i IPI(z)='Ylz «P2(z)= Y2z+ 'Yli for different values of parametery. A point is coloredred if 4>1is the last transformation used, otherwise it is colored c!I3(z)= (I-'YI-'Y2>z+ ('YI+'Y2>i green. The area in which green and red points are adjacent IP4(Z)= Y2zeia+ 'Yli to eachother appearsas yellow. Modification of the numer- ical parametersreveals interesting variations of the basic IPs(z)= (I-'YI-'Y2>ze-ia+ ('YI+'Y2>i dragoncurve shape. Figure 65 presentsthe images resulting from iterating the Remark 6.1. The use of complex variables emphasizesan similarities IPI - IPs for three different valuesof parameters analogy between the Koch curves and the Julia sets. For 'YI and 'Yz. In all cases, IX=::.. As in Example 6.2, example,a Julia set can be generatedusing the inverseitera- 6 tion method,by iterating two mappings: modification of the numerical parametersreveals interesting shapevariations. fJ(z) = +;IZ+T h(z) = -;Iz+T . The particular mappingsgenerating a Koch curve and a Julia set are different, but the underlying iterative algorithm is the 7. THE REPELLING METHOD FOR KOCH CURVE same. GENERATION. Example 6.3 (Based on [Demko et al. 1985]). Plate 6.3 The setsof equationsconsidered in the previous section shows the curve generatedby the union of three transforma- defined Koch curves as attractorsof dynamic processes.In this section we address the problem of describing Koch tions: curves as repellerso The basic conceptis to use reciprocal 1 1. -Z+-I mappings

.1 1 1 -I-X cI>3(z) = -z+-e 6 . 2 2 As previously, the point colors indicate the last transforma- tion used. Note that the figure obtained is the Sierpiflski gasket [Mandelbrot 1982]. Transformations$1-413 provide an interesting characterizationof this well-known curve: the Sierpiflski gasket is the smallest nonernpty set closed with respectto three scaling transformations. Their centers(fixed points) lie at the vertices of an equilateral triangle and the scaI mg'. rauos are equaI to-.1 2 (0.0) (0.0) Fig. 6.4. Productionof the Koch systemgenerating twig-like shapes.

Graphics Interface '88 sequenceof transfonnations«Pj;I«Phl . .. which doesnot take a 11/ x to infinity. This observationcan be used a basis for gen- erating imagesof Koch curves, althoughonly finite transfor- mation sequencesand finite distanceson the plane can be consideredin practice. The algorithm proceedsas follows. . Define a window on the image plane to establishthe area of interest within which the curve will be traced. Subdivide this window into an array of samplepoints which will correspondto the pixels on the screen(for example, each sample will representone pixel if no oversamplingis used.) Assume the maximum length N of the transfonnation sequenceconsidered. Define a "large" circle Q (including the curve C-> which will be usedto test whetherpoints tend to infinity. ~ . Partition the plane into regions Dj such that for any x E C- ("\ Dj the function «Pilc 11>-1takes point x to some point of C_: xcIIil E C_. According to the Theorem 7.1, at least one such function «Pil exists, Fig 6.5. "Twigs" generatedusing the attractivemethod. hencethis partition is feasible. a) 11 = 0.5,12 = 0.3.b) 11= 12= 0.5. For each sampling point Xo calculate a sequence of c) 11 = 0.2, 12 = 0.3. . points xO,xI,x2.'"according to the rule: It In all three cases,10. . . ,massociated with K. A point x cle Q which containsthe curve C-. X docsnot belongto C_. belongs to the limit curve C- if and only if there exists a On the other hand, if after N iterationsX stayswithin Q. it function jC jle C_. is assumedthat X E C_. In fact, in this latter casex can be Proof. According to the Theorem 5.2a, C- = C_jC

j= x, or xjl= y e C_. screenresolution. On the other hand, if ;xIIIjl e C- then xjlj= x e C_. 0 Example 7.1. Let us apply the repelling methodto generate Theorem 7.2. Consider a Koch systemK with the contrac- an image of the Sicrpiflski gasket According 10 Example tion ratio 1 < I and let 10. . . ,m associatedwith K. If a point x does not belong to the limit curve C- then for any infinite sequenceof and the scaling ratios equal to 1.. Obviously, the reciprocal transformations ",:-1 ",:-1 . . . 2 'I'll 'l'jz "",:-1 ",:-1 lim p( . . . C ) =00 . n-.- ""I'll 'l'J.'- Proof. Consider a sequence of similarities $j. . . . $j, and a point v e C_. Since the set C- is closed with respect to all similarities $j c: II> (Theorem 5.2a), the point u = vC/Ij.. . . $j, also belongs to C_. Now, let us consider point y = x$];l . . . $kl. According to the Definition 4.3 and Lemma 5.2, p(x, u) ~ Y'p(y, v), or: p(y, v) ~ y"p(x, u) . The distance p(x, u) is greater then zero, because xe C- and the set C- is closed. Thus, y"p(x, u) -t 00 with n -t 00, and consequently p(y, v) -t 00. Since v e C- and C- is bounded (Theorem 5.1), the distance between y = x$];l . . . $kl andC- tendsto infinity with n -t 00. 0 Fig. 7.1. Relative position of the scalingcenters PI - PJ and domainsDI - DJ for generatingthe Sierpiilski From Theorems 7.1 and 7.2 it follows that a point x gasketusing the repelling method. All scalingratios belongs to the curve C- if and only if there exists an infinite are equal to 2.

Graphics Interface '88 Fig. 7.2. The Sierpihski gasketgenerated using Fig. 7.5. Relative position of the scalingcenters PI - Ps the repelling method. and domainsDI - Ds for generatingthe Sicrpinski carpet. transformations $11~13 are also scalings, with the same The scalingratios for Db D3. Ds andD7 are centers and the scaling ratio equal to 2. In order to deter- equal to 2..fi. The scaling ratios for D2. D4. D6 mine their domains Dp let us refer to Plate 6.3. It shows and Ds arc equalto 2. that the gasket can be divided into three subgaskets(the red satisfy the condition: one, green and yellow) which belong to different domains. Thus, the domain boundariescan be defined as the bisectors if z eDj n C- then z cIIjl e C- . of the line segmentsconnecting pairs of the scaling centers (Fig. 7.1). The resulting image of the Sierpihski gasket In principle, the repelling method for generatingKoch obtainedusing the repelling method is shown in Fig. 7.2. curves is analogousto the widely used method for generat- ing colorful imagesof Julia sets. However, the necessityof Example 7.2. The conceptof using setsof scalingscan also partitioning the plane into domainsDj can make it difficult be used to generate other fractals. Figures 7.3 and 7.5 to apply to some Koch curves. For example,refer to the define the scalings and their respectivedomains which were Example 6.2 and Plate 6.2. According to the coloring rules used to generateimages shown in Plates 7.4 and 7.6. The assumed,red points belong to the domain Dl and green fractal in Plate 7.4 consists of an infinite number of points belong to the domain Dz. Plate 6.2b indicates that snowflake curves. The fractal in Plate 7.6 is the Sierpiflski the boundary between these two domains can itself be a carpet Note that in this latter case two different scaling fractal line. Domain definition in the cases (c) and (d) ratios were used. appearsto be even more enigmatic. Example 7.3. Plate 7.8 shows the repelling version of a If the plane cannot be easily subdividedinto domains, "twig" from Example 6.4, with parameters 11 = 12 = 1.. and the fractal can be still generatedusing a "brute force" variant 3 of the repelling method. The idea is to keep track of all a = Partition of the plane into domains DI Ds is ~. - points resultin¥ from the repetitive applicationof transforma- given in Fig. 7.7. The exact positions of domain boundaries tions cIIjlC <1>-to the samplingpoint xo, as long as they stay were arbitrarily chosenfrom the range of possibilities which within the circle n. Formally, if Xo is the initial sampling

Fig. 7.7. Partition of the plane into domainsD, - Ds for generatinga twig using the repelling method. Fig. 7.3. Relative position of the scaling centersPI - P6 Transformations$ll - $Sl are the reciprocals and domainsDI - D6 for generatingthe of the transformationsfrom Example6.4. For orientation, "multi-snowflake" of Plate 7.4. the dashedlines show the correspondingfirst-order All scaling ratios are equal to 3. curve CI.

Graphics Interface '88 point, the set Xn of points consideredafter the nth iteration step is given by the recursiveformula: Xo ={X'o} X,..,I =Xi «1>-1(")Q The iteration stops if the set Xn becomesempty or the index n reaches a limit N. As previously, the final value of n ~ determinesthe color of the point xo. Example 7.4. Plate 7.9 shows the repelling version of the dragoncurve from Plate 6.2b.

8. CONCLUSIONS. This paper presentstwo methods for generatingKoch curves. They are analogousto the commonly used iterative methodsfor producing images of Julia sets. The attractive - Fig. 8.1. An examplenonunifonn fractal methodis basedon a characterizationof Koch curvesas the generatedusing the attractivemethod. smallest nonempty sets closed with respect to a union of similarities on the plane. This characterizationwas first stu- sideredwas limited to the direct similarities. It would died by Hutchinson. The repelling method is in principle be interestingto remove this limitation and investigate dual to the attractive one, but involves a nontrivial problem the class of curves generated by arbitrary linear of selecting the appropriate transformationto be applied at transfonnationson the plane. While the straightforward each step. Both methods are illustrated with a number of correspondencewith the Koch curves will probably be computer-generatedimages. lost, new interestingfractal imagesmay be produced. . This papershows that the usual descriptionof the Koch The Koch systems discussed in this paper have the axiom limited to a single vector and use only one produc- curves in tenns of an iterative geometric construction tion. Theserestrictions can be removed by grouping all vec- can be replaced by an algebraic characterization. A tors into classes. The applicable production is then deter- "dual" questionapplies to the Julia sets. Their known mined by the class a given vector belongs to. Each produc- descriptionsrefer to the function iteration. Is it possi- tion also specifiesthe target classesfor all resulting vectors. ble to defineJulia setsby geometricconstructions? A correspondingapproach can be applied to generateKoch . Our resultsappear to be related to the theory of iterated curves by function iteration. In this case, a point in the function systems originated by Barnsely and Demko plane is characterizedby its position and an attribute or [1985] (for further results, see [Demko, Hodges and state. A typical transformation$j has a form "if point x is in Naylor 1985, Levy-Vehel and Gagalowicz 1987]). state sp than take it to point y and make the state of the However, these systems operate in a probabilistic result equal to Sq." For an example of an image generated manner,while our approachis purely detenninistic. It using this technique, see Fig. 8.1. This branching shape would be thereforeinteresting to investigatethe role of belongsto a class termed "nonuniform fractals" by Mandel- probability in iterative function systems, and conse- brot [1982] and cannot be generatedby a' Koch systemwith quently establish their relation to the "attractors and a single production. A fonnal characterizationof Koch sys- repellersof Koch curves" presentedin this paper. temswith multiple productionsis left for further research. Finally, we would like to convey our impressionon the There are also many other problems open for further general character of the reported research. We find it research. Someof them are listed below. remarkablethat it combinesnotions from areasof mathemat- . The repelling method for generating Koch curves ics and computerscience which traditionally have beenper- presentedin Section 8 relies on a partition of the plane ceived as quite unrelated. To name a few, we draw on into domains Dr However, domains Dj are defined results of the theory of formal languages,geometry, topol- only for the points which belong to the curve C_, and ogy and complex analysis, and we illustrate them using an arbitrary partition can be assumedoutside of it. Are computer-generatedimages of fractals. Extrapolating this some of these partitions more "natural" then others? experience,we believe that fractals may have great yet What is the impact of the partitions used on the images largely unexploited educational potential as a visually generatedby the repelling method? appealing method for illustrating various concepts of mathematicsand computerscience. Interestingly,the educa- The correspondencebetween Koch curvesand Julia sets . tional applications were also presented as the original would be even more convincing if it could be illus- motivation of Koch's work. trated by a continuous transformationof a Koch curve (such as the ) into a Julia set (such as the self-squareddragon). . This paper focused on the correspondencebetween the generative and the algebraic characterizationof Koch curves. Consequently,the class of transformationscon-

Graphics Interface '88 Von Koch, H. [1905]: Une methode geometrique ACKNOWLEDGMENT. f.lementairepour l'etude de certaines questionsde la Dr. kindly brought to our attention throne des courbesplanes. Acta mathematica30, pp. the paper by Hutchinson. Lynn Mercer and Jim Hanan 145-174. volunteered valuable assistance in preparing illustrations included in this paper. This researchcould not have been done without the support and facilities provided by the Department of Computer Science at the UniversitY of Regina. The support from the Natural Sciences and Engineering Research Council of Canada (grant number A0324) is also gratefully acknowledged.

REFERENCES Bamsley, M. F. and Demko, S. [1985]: Iterative function systemsand the global construction of fractals. Proc. R. Soc. London A 399, pp. 243-275. Delling, F. M. [1982a]: Recurrent sets. Advances in mathematics44, pp. 78-104. Dekking, F. M. [1982b]: Recurrent sets: a fractal formal- ism. Delft UniversitY of Technology, Department of Mathematicsand Infonnatics Report 82-32. Demko, S., Hodges, L. and Naylor, B. [1985]: Construction of fractal objects with iterated function systems. Com- puter Graphics 19 Nr. 3, pp. 271-278. Grllnbaum, B. and Shephard,G. [1987]: Tilings and pat- terns. W. H. Freeman,New York. Hutchinson,J. E. [1981]: Fractals and self-similaritY. Indi- ana University Mathematics Journal 30, No.5, pp. 713-747. Kuratowski, K. [1972]: Introduction to set theory and topol- ogy. PergamonPress, Oxford, and Polish Scientific Pub- lishers, Warsaw. Levy-Vehel, J. and Gagalowicz, A. [1987]: Shapeapproxi- mation by a fractal model. Eurographics '87, North- Holland, pp. 159-180and 572. Lindenmayer, A. [1968]: Mathematical models for cellular interaction in development,Parts I and II. Journal of theoretical biology 18, pp. 280-315.' Mandelbrot, B. B. [1982]: The fractal geometryof nature. W. H. Freeman,San Francisco. Norton, A., et al. [1986]: Dynamics of ei9x(1-x). Film included in Siggraph Video ReviewIssue 25. Peitgen, H.-a. and ~chter, P. H. [1986]: . Springer-Verlag, Berlin - Heidelberg - New York - Tokyo. Prusinkiewicz, P. [1986]: Graphical applications of L- systems.Proceedings of GraphicsInterface' 86 - Vision Interface '86, pp. 247-253. Rozenberg,G. and Salomaa,A. [1980]: The mathematical theory of L systems. AcademicPress, New York. Smith, A. R. [1984]: Plants, fractals and fonnallanguages. ComputerGraphics 18 Nr. 3, pp. 1-10. Szilard, A. L. and Quinton, R. E. [1979]: An interpretation for DOL systems by computer graphics. The Science Terrapin 4, pp. 8-13.

Graphics Interface '88