Author Topic: Fraktal-Bäume  (Read 3563 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10762
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Fraktal-Bäume
« on: 2004-Mar-29 »
Na, wie wär's mit schönen 3D-Bäumen mit Blättern usw...? Hier ist ein einfaches Grundgerüst dafür:

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, maxdepth

LOCAL ex, ey, ez, px, py, pz, lngth, ln_bottom, dphi, dpsi
LOCAL 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, col
ENDFUNCTION


Und ein Bild:

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5081
  • O Rly?
    • View Profile
Fraktal-Bäume
« Reply #1 on: 2007-May-13 »
bild fehlt XD
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard