Arbre récursif en python visual
Résolu
Utilisateur anonyme
-
Utilisateur anonyme -
Utilisateur anonyme -
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....
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....
A voir également:
- Arbre récursif en python visual
- Visual petanque - Télécharger - Sport
- Visual c++ 2019 - Guide
- Visual paradigm - Télécharger - Gestion de données
- Citizen code python avis - Accueil - Outils
- Visual watermark - Télécharger - Photo & Graphisme