# Algorithm for Generating the Flower of Life Pattern

## Section 1. Basic Geometry and Algorithms. The alogrithms below show how to calculate the origin of each unit circle for the first few rotations. A rotation may be defined as traveling once around the perimeter of the pattern, drawing a new unit circle at the outer most point where two or more circles intersect. This process may be viewed, by analogy, as the hand of a clock sweeping around in a circle. At each intersection point a unit circle is drawn, centered at the end of the clock hand. Thus the location each unit circle in a rotation may be determined by calculating the polar coordinates of the unit circle's center.

Since the html canvas primative functions use rectangular coordinates, we translate the polar coordinates to rectangular coordinates using the equations

xc = radial distance  ·  cos(angular offset)
yc = radial distance  ·  sin(angular offset)
Using polar coordinates to specify the origin of each unit circle allows for a very simple algorithm to generate each successive rotation. The center of each unit circle is computed by the calculating its radial offset from the center of the first circle and calculating the angular offset from the horizontal x axis.

In section 2, we will generalize on the algorithms discribed in this section. The generalized algorithm will allow drawing patterns for any arbitrary number of rotations. ### First Rotation

1. φ ← π/2
2. r ← 1
3. draw unit circle centered at (r, φ)
4. φ ← φ + π/3
5. repeat steps 3 and 4 a total of five more times ### Second Rotation

1. φ ← 0
2. r ← √3
3. draw unit circle centered at (r, φ)
4. φ ← φ + π/3
5. repeat steps 3 and 4 a total of five more times ### Third Rotation

1. φ ← π/2
2. r ← 2
3. draw unit circle centered at (r, φ)
4. φ ← φ + π/3
5. repeat steps 3 and 4 a total of five more times ### Forth Rotation

1. φ ← sin-1[1 / (2√7)]
2. γ ← 0
3. r ← √7
4. draw unit circle centered at (r, γ + φ)
5. draw unit circle centered at (r, γ - φ)
6. γ ← γ + π/3
7. repeat steps 4 through 6 a total of five more times ### Fifth Rotation

1. φ ← π/2
2. r ← 3
3. draw unit circle centered at (r, φ)
4. φ ← φ + π/3
5. repeat steps 3 and 4 a total of five more times ### Sixth Rotation

1. φ ← sin-1(1 / √13)
2. γ ← 0
3. r0 ← 2√3
4. r1 ← √13
5. draw unit circle centered at (r0, γ)
6. draw unit circle centered at (r1, γ + φ)
7. draw unit circle centered at (r1, γ - φ)
8. γ ← γ + π/3
9. repeat steps 5 through 8 a total of five more times