Téléchargement
illégal
Posez votre question Signaler

Arbre récursif en python visual [Résolu]

drackenshtein 748Messages postés 31 janvier 2008Date d'inscription 1 mars 2012Dernière intervention - Dernière réponse le 3 janv. 2009 à 15:52
Bonjour,
Je dois créer un arbre en 3d avec un tronc, trois branches principales, desquelles partent 3 branches et ainsi de suite.
voici mes fonctions :
def tronc():
tronc=cylinder(pos=(0,-4,0), axis=(0,taille,0), radius=rayon)
tronc.color=(0.8,0.4,0.1)
def branche1(x, y, taille):
branche1=cylinder(pos=(x,y,0), axis=(taille*0.86*coef,taille*0.5*coef,0), radius=rayon*coef)
branche1.color=(0.8,0.4,0.1)
def branche2(x, y, taille):
branche2=cylinder(pos=(x,y,0), axis=(taille*0.86*coef,taille*0.5*coef,0), radius=rayon*coef)
branche2.color=(0.8,0.4,0.1)
branche2.rotate(angle=(pi/3)*2, axis=(0,1,0), origin=(0,6,0))
def branche3(x, y, taille):
branche3=cylinder(pos=(x,y,0), axis=(taille*0.86*coef,taille*0.5*coef,0), radius=rayon*coef)
branche3.color=(0.8,0.4,0.1)
branche3.rotate(angle=(pi/3)*4, axis=(0,1,0), origin=(0,6,0))
def branches(n):
if n!=0 :
branche1(x+taille*0.86, y+taille*0.5, taille*coef)
branches(n-1, k)
branche2(x+taille*0.86, y+taille*0.5, taille*coef)
branches(n-1, k)
branche3(x+taille*0.86, y+taille*0.5, taille*coef)
branches(n-1, k)
socle()
tronc()
branches(n)
J'ai deux problèmes : comment retrouver la position origine de la branche suivante (mon x et mon y sont censés faire ce boulot mais ça ne marche pas) et comment orienter la branche à partir de l'axe de la branche précédente?
Si quelqu'un pouvait me donner ne serait-ce que des idées....
Lire la suite 

Arbre récursif en python visual »

1 réponses
Réponse
+0
moins plus
c'est bon j'ai trouvé, merci pour votre aide.
Ajouter un commentaire
Ce document intitulé « arbre récursif en python visual » issu de CommentCaMarche (www.commentcamarche.net) est mis à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de cette page, dans les conditions fixées par la licence, tant que cette note apparaît clairement.
Dossier à la une
Passage au tout numérique : quel coût pour les particuliers ?