Created
September 10, 2015 08:09
-
-
Save ydm/0ce6687b38583f7d3f5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import cmath | |
| import math | |
| import matplotlib.pyplot as plt | |
| def linear(a, z, n=100): | |
| yield z | |
| for _ in range(n): | |
| z = a * z | |
| yield z | |
| def main(): | |
| length = 0.9 | |
| angle = 1 | |
| a = complex(math.sin(angle), math.cos(angle)) * length | |
| seed = complex(1, 0) | |
| sequence = [c for c in linear(a, seed, 100)] | |
| real = [c.real for c in sequence] | |
| imag = [c.imag for c in sequence] | |
| plt.plot(real, imag) | |
| plt.show() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment