Recursive fonctions (fractal tree)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Recursive fonctions (fractal tree)

matplotlib - users mailing list
Hi, I have to create a reccursive function with matplotlib in order to make a
fractal tree.
That's my fonction at this moment :

import matplotlib.pyplot as plt
from math import *

def Drawn_(P,L,a,c,e):  
    X = L*cos(a) + P[0]
    Y = L*sin(a) + P[1]
    M=[X,Y]
    plt.axis('equal')
    plt.plot([P[0],X],[P[1],Y],color=c,lw=e)
    return M              


def Tree(P,L,k,a,N,c):
    A=Drawn_(P,L,a+(pi/4),c,1)
    while N>>0:
        N=N-1
        Arbre(A,L*k,k,0,N,'black')
        Arbre(A,L*k,k,(pi/2),N,'green')
   
I had some pictures to show what are the problems.
<http://matplotlib.1069221.n5.nabble.com/file/t5278/1-What_I_have_to_do.jpg>
<http://matplotlib.1069221.n5.nabble.com/file/t5278/2-The_tree_that_I_have.jpg>

For the moment it don't work correctly because I can't create the tree with
random angles and I don't know how to solve the problem and create the
correct tree with recursivity..
Can someone help me please ? :)
I have to restart the fonction or can we had, or change somethings to make
it work ?



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users