Fraktal-Bäume

Previous topic - Next topic

Kitty Hello

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:

Schranz0r

bild fehlt XD
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard