File:Fibonacci word fractal, order 18.svg
Original file (SVG file, nominally 826 × 1,979 pixels, file size: 621 KB)
Captions
Summary
editDescriptionFibonacci 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
editThis 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 |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 00:29, 9 February 2023 | 826 × 1,979 (621 KB) | Cosmia Nebula (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on el.wikipedia.org
- Usage on en.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 660.40906pt |
---|---|
Height | 1582.8818pt |