Created
April 15, 2012 05:24
-
-
Save iizukak/2390231 to your computer and use it in GitHub Desktop.
Fractal Leaf
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
| import random | |
| def leaf(a): | |
| prob = random.randint(1,100) | |
| #print prob | |
| if prob == 1: | |
| a[0] = 0.0 | |
| a[1] = 0.16 * a[1] | |
| elif 1 < prob and prob <= 85: | |
| a[0] = 0.85 * a[0] + 0.04 * a[1] | |
| a[1] = -0.04 * a[0] + 0.85 * a[1] + 1.6 | |
| elif 85 < prob and prob <= 92: | |
| a[0] = 0.2 * a[0] - 0.26 * a[1] | |
| a[1] = 0.23 * a[0] + 0.22 * a[1] + 1.6 | |
| elif 92 < prob and prob <= 100: | |
| a[0] = -0.15 * a[0] + 0.28 * a[1] | |
| a[1] = 0.26 * a[0] + 0.24 * a[1] + 0.44 | |
| a = [0.0, 0.0] | |
| for i in range(100000): | |
| print(a[0], a[1]) | |
| leaf(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment