File:Fibonacci word fractal, order 18.svg
Contents
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionFibonacci word fractal, order 18.svg |
English: Fibonacci word fractal, order 18, with the sub-rectangles colored
Drawn in python. ```python from itertools import count, islice, groupby from math import floor, sqrt import matplotlib.pyplot as plt def sturm_word(ratio): xs = count(1) ys = map(lambda x : x * ratio, xs) fw = islice(groupby(map(floor, ys)), 1, None) return map(lambda x : 2 - len(list(x[1])), fw)
# if the symbol 0 is in an even position then turn left, else turn right def fib_line(fib_word, origin=(0, 0), length=1, angle=0): angle_dict = {
0: (1, 0),
90: (0, 1),
180: (-1, 0),
270: (0, -1)
}
is_even = True
x0, y0 = origin
current_angle=angle
while True:
dx, dy = angle_dict[current_angle]
x1, y1 = x0 + dx, y0 + dy
yield (x0, y0, x1, y1)
if next(fib_word) == 0:
if is_even:
current_angle += 90
else:
current_angle -= 90
current_angle %= 360
x0, y0 = x1, y1
is_even = not is_even
golden_ratio = (sqrt(5) - 1)/2 fib_word = sturm_word(golden_ratio) def fibs(n): f0, f1 = 0, 1 for _ in range(n): f0, f1 = f1, f0+f1 return f0 xfirst, yfirst, xlast, ylast = 0, 0, 0, 0 golden_ratio = (sqrt(5) - 1)/2 fib_word = sturm_word(golden_ratio) i = 0 fib_i = fibs(i) limit_i = 18 plt.figure (figsize= (20, 32)) for line_i, (x0, y0, x1, y1) in enumerate(fib_line(fib_word, origin=(0, 0), length=0.1, angle=0)): plt.plot([x0, x1], [y0, y1], 'k')
if line_i > fib_i - 2:
i, fib_i = i+1, fibs(i+1)
xfirst, yfirst, xlast, ylast = xlast, ylast, x1, y1
color = 'blue' if i % 2 == 0 else 'green'
r = plt.Rectangle((xfirst, yfirst), xlast-xfirst, ylast-yfirst, fc=color, ec='black', alpha=0.3)
plt.gca().add_patch(r)
if i > limit_i:
break
plt.gca().set_aspect('equal') plt.axis('off') plt.savefig('fib_word.svg', bbox_inches=0, transparent=True) ``` |
| Date | |
| Source | Own work |
| Author | Cosmia Nebula |
Licensing
| This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
| The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
Captions
Items portrayed in this file
depicts
some value
8 February 2023
image/svg+xml
636,272 byte
5436adb26a1f2b66ce13695cb6d0b822c655253c
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 01:29, 9 February 2023 | 826 × 1,979 (621 KB) | wikimediacommons>Cosmia Nebula | Uploaded own work with UploadWizard |
File usage
There are no pages that use this file.