Author Topic: Factal Trees  (Read 5140 times)

Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10817
• here on my island the sea says 'hello'
Factal Trees
« on: 2004-Mar-29 »
Well, how about drawing some nice 3D Trees with leaves and so on? Here's the basic framework needed:

Code: (glbasic) [Select]
`// --------------------------------- //// Project:// Start: Monday, March 29, 2004// IDE Version: 1.40327// rule = â€œl [ + l ] l [ - l] lâ€ [Jürgens Hartmut, Peitgen Heinz-Otto, Saupe Dietmar://                                Fraktale - eine neue Sprache für komplexe Strukturen,//                                Spektrum der Wissenschaft (9/1989), p.62.] with// l = line// + = +28.58 degrees// - = -28.58 degrees// [ = start of a branch// ] = end of a branch    NewBranch(200,200,0, 0, -90, 0, 10) SHOWSCREEN MOUSEWAIT// ------------------------------------------------------------- //// -=#  NEWBRANCH  #=-// ------------------------------------------------------------- //FUNCTION NewBranch: x, y, z, phi, psi, depth, maxdepthLOCAL ex, ey, ez, px, py, pz, lngth, ln_bottom, dphi, dpsiLOCAL n, nbranches, col lngth = 100/(1+depth) ln_bottom = lngth*COS(psi) nbranches = 2 ex = x + COS(phi)*ln_bottom ey = y + SIN(psi)*lngth ez = z + SIN(phi)*ln_bottom IF (depth FOR n=1 TO nbranches pos = n/(nbranches+1) px = x+(ex-x)*pos py = y+(ey-y)*pos pz = z+(ez-z)*pos dphi = phi + (RND(2)-1)*28.58 dpsi = psi + (RND(2)-1)*28.58 NewBranch(px, py, pz, dphi, dpsi, depth+1, maxdepth) NEXT ENDIF col = RGB(200 - 200*(depth/maxdepth), 64+128*(depth/maxdepth), 0) // Front DRAWLINE x, y, ex, ey, col // Left DRAWLINE z+120, y, ez+120, ey, col // Top DRAWLINE x, z+320, ex, ez+320, colENDFUNCTION`

And an image:

goomoo

• Guest
Factal Trees
« Reply #1 on: 2006-Mar-19 »
Cool!

Thanks for share!

rocko

• Guest
Factal Trees
« Reply #2 on: 2006-May-09 »
Nice!

• code monkey