next up previous contents index
Next: Non-Euclidean Geometry Up: Domains and Plotting Previous: Calculus Plotting   Contents   Index

Recursive Fractal Curves

Consider a path made up of equal-length segments that can point at any angle of the form $ 2\pi k/n$ radians, for $ 0\leq k<n$, like spokes on a wheel. A path is specified by a finite sequence of integers, taken modulo $ n$. For example, if $ n=6$, then the sequence $ 0, 1, -1, 0$ corresponds to the ASCII path _/\_. ePiX's fractal approximation starts with such a ``seed'' then recursively (up to a specified depth) replaces each segment with a scaled and rotated copy of the seed. The seed above generates the standard von Koch snowflake fractal. In code:

  const int seed[] = {6, 4, 0, 1, -1, 0};
  fractal(P(a,b), P(c,d), depth, seed);
The first entry of seed[] (here 6) is the number of ``spokes'' $ n$, the second (4) is the number of terms in the seed, and the remaining entries are the seed proper. The final path joins $ (a,b)$ to $ (c,d)$. The number of segments in the final path grows exponentially in the depth, so depths larger than 5 or 6 are likely to exceed the capabilities of LATEX and/or PostScript.
Figure 3.3: Successive iterations of {4,8,0,1,0,3,3,0,1,0}


next up previous contents index
Next: Non-Euclidean Geometry Up: Domains and Plotting Previous: Calculus Plotting   Contents   Index
Andrew D. Hwang 2004-09-04