English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 16 July 2011, 10:48   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 746
Fractals, how to??

Was wondering if anyone here every wrote any code to generate a fractal image? I was doing a little research and found this site http://library.thinkquest.org/3493/frames/fractal.html with this basic example in.

Code:
CLS
FOR i = 1 TO 300
	FOR j = 1 TO 150
		c1=-2+4*i/300
		c2=2-4*j/300
		x=c1
		y=c2
			FOR n = 1 TO 30
			x1=x*x-y*y+c1
			y1=2*x*y+c2
			r=x1*x1+y1*y1
			IF r > 4 THEN GOTO 1000
			x = x1
			y = y1
			NEXT n
		PSET(i, j)
		PSET(i,300-j)
	1000 NEXT j
NEXT i
END
Just wondered if anyone had any experience with this kinda stuff?

Edit: Thats a Mandelbrot btw.

Last edited by h0ffman; 16 July 2011 at 10:59.
h0ffman is online now  
Old 17 July 2011, 02:19   #2
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
No real experience, I have created one before but have no clue how to manipulate the routine to zoom in on a particular area of the fractal. Elena Noveretti had a great website ( www.elena-fractals.it ) full of awesome fractals she created, but the website seems to be down
She was interviewed in issue 24 of Total Amiga, which included a few pictures of the fractals she created along with the basics of creating fractals.

You can find loads of awesome fractal creators here, and I ended up looking at some cool ones created by Jennifer Scotland (Sasqui), which can be found here.


Regards,
Lonewolf10
Lonewolf10 is offline  
Old 17 July 2011, 09:14   #3
Dan
Registered User
 
Dan's Avatar
 
Join Date: Nov 2004
Location: Germany
Posts: 629
Quote:
Elena Noveretti had a great website ( www.elena-fractals.it ) full of awesome fractals she created, but the website seems to be down
Lucky web archive has still a copy of it
http://web.archive.org/web/200302071...a-fractals.it/
but only some of the big pictures are available.
Dan is offline  
Old 17 July 2011, 10:05   #4
zardoz
Zone Friend
 
zardoz's Avatar
 
Join Date: Oct 2004
Location: Wales
Age: 53
Posts: 163
pick a language, write your code and press go.

My first Mandelbrot generator was written in Spectrum basic. It took about a minute to plot a pixel so I left it on overnight and by the morning my speccy had died :-(

Quote:
Originally Posted by h0ffman View Post
Code:
CLS
FOR i = 1 TO 300
    FOR j = 1 TO 150
        c1=-2+4*i/300
        c2=2-4*j/300
        x=c1
        y=c2

So i and j are your screen or bitmap coordinates - in this case your output will be 300 x 150 pixels
c1 and c2 are the area of the graph that you are plotting. Your x axis is 'real numbers' and your y axis 'imaginary numbers'.
So C1 goes from -2 to +2 in this case
c2 goes from -2 to 0

To zoom in you'd choose different values for C1 & C2

Last edited by TCD; 17 July 2011 at 10:39.
zardoz is offline  
Old 17 July 2011, 11:54   #5
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 746
Cheers zardoz, will have fire up Devpac now and see how fast I can get this baby to plot.
h0ffman is online now  
Old 19 July 2011, 03:02   #6
victim
Registered User
 
Join Date: Mar 2009
Location: N/A
Posts: 23
Hi h0ffman !

Here I have a small mandelbrot fractal developed.
It is still not very optimized, but it runs on all Amigas.
The code is very quick and dirty programmed and only for a example.

Code:
;******    Date:    19.07.2011    Prog: Mandelbrot-Fractal
;******
;******    Autor:    Victim of Savage

planesize =    44*286
xv    =    -21403
yv    =    -10240
xmax    =    -30352-xv
xmin    =    -xv
ymin    =    22000+yv
ymax    =    yv
deep    =    32
factor    =    1024
xsize    =    352
ysize    =    286
bplanes    =    5

    section    code,code_c
    
start:    movem.l    d0-d7/a0-a6,-(a7)

    lea    $dff000,a6
    move    #$01e0,$96(a6)
    move    #$4000,$9a(a6)
    lea    CopperList,a1
    move.l    a1,$84(a6)
    move    #$8180,$96(a6)

    bsr    InitPlanes    
    bsr    Colors
    bsr    CalcMandel
    
maus:    btst     #6,$bfe001
    bne     maus
end:    move    #$83e0,$dff096
    movem.l    (a7)+,d0-d7/a0-a6
    rts

Colors:    lea        Copcolors,a0
    move    #$0180,d0
    move    #$0000,d1
    moveq    #15,d2
loop:    move    d0,(a0)+
    move    d1,(a0)+
    addq    #2,d0
    add        #$0100,d1
    dbf        d2,loop    
    move    #$0f00,d1        
    moveq    #14,d2
loop2:    move    d0,(a0)+
    addq    #2,d0            
    add        #$0010,d1
    move    d1,(a0)+
    dbf        d2,loop2
    rts
        
InitPlanes:
    lea.l    CopperPlanes,a0
    move.l    plane0,d0
    moveq    #4,d7
Copy2:    move    d0,6(a0)
    swap    d0
    move    d0,2(a0)
    swap    d0
    add.l    #planesize,d0
    addq.l    #8,a0
    dbf        d7,Copy2
    rts

CalcMandel:
    move.l     #xmax-xmin,d0
    move.l     #xsize,d1
    divs     d1,d0
    move     d0,a2
    move.l     #ymax-ymin,d0
    move.l     #ysize,d1
    divs     d1,d0
    move     d0,a3
    move.l     #xmin,d6
    move.l     #ymax,d7    
forz:    sub.l    a1,a1
    btst     #6,$bfe001
    beq     end
forss:    suba.l    a5,a5
fors:    suba.l    a0,a0
    lea        empty(pc),a0
    movem.l    (a0)+,d0-d4
while:    move.l     #factor,d5
    muls     d0,d1
    add.l     d1,d1
    asr.l     #5,d1
    asr.l     #5,d1
    asr.l     #3,d1
    sub.l     d7,d1
    move.l     d2,d0
    sub.l     d3,d0
    sub.l     d6,d0
    move.l     d0,d2
    muls     d2,d2
    asr.l     #5,d2
    asr.l     #5,d2
    asr.l     #3,d2
    move.l     d1,d3
    muls     d3,d3
    asr.l     #5,d3
    asr.l     #5,d3
    asr.l     #3,d3
    addq.l     #1,d4
    cmp     #deep,d4
    bge     weiter1
    asl.l     #5,d5
    sub.l     d3,d5
    sub.l     d2,d5
    bge     while
    bra     weiter2
weiter1:
    moveq     #0,d4
weiter2:
    lea     plane0,a0
    moveq     #bplanes-1,d0
next:    move.l     (a0)+,a6
    asr     #1,d4
    roxl     (a6)
    dbf     d0,next

    add.l     a2,d6
    addq.l     #1,a5
    cmp.l     #15,a5
    ble     fors

    lea     plane0,a0
    moveq     #bplanes-1,d0
next1:    addq.l     #2,(a0)+
    dbf     d0,next1

    addq.l     #1,a1
    cmp.l     #xsize/16-1,a1
    ble     forss
    move.l     #xmin,d6
    sub.l     a3,d7
    addq.l     #1,a4
    cmp.l     #ysize-1,a4
    ble     forz
    rts

empty:    blk.l    5,0
        
    section    copperlist,DATA_c
    
CopperList:    
        dc.l    $01200000,$01220000
        dc.l    $01fc0000
        dc.l    $01020000,$01040000
        dc.l    $01060000
        dc.l    $01080000,$010a0000
CopperPlanes:
        dc.l    $00e00000,$00e20000
        dc.l    $00e40000,$00e60000
        dc.l    $00e80000,$00ea0000
        dc.l    $00ec0000,$00ee0000
        dc.l    $00f00000,$00f20000
        dc.l    $008e1a71,$009037e1
        dc.l    $00920030,$009400d8
        dc.l    $01005200
CopColors:
        blk.l    32        
        dc.l    -2

plane0:    dc.l    PlaneBuffer
    dc.l    PlaneBuffer+planesize
    dc.l    PlaneBuffer+planesize*2
    dc.l    PlaneBuffer+planesize*3
    dc.l    PlaneBuffer+planesize*4

        section Planes,BSS_c

PlaneBuffer:    ds.b    planesize*5
Here is a link to an interview with Elena Novaretti from the year 2006. The interview is very well done and also provides the mathematical foundations of fractal programming.

http://www.savage-crew.de/TA24_ElenaIview_Full.pdf



so long...
victim


Quote:
Originally Posted by h0ffman View Post
Was wondering if anyone here every wrote any code to generate a fractal image? I was doing a little research and found this site http://library.thinkquest.org/3493/frames/fractal.html with this basic example in.

Code:
CLS
FOR i = 1 TO 300
    FOR j = 1 TO 150
        c1=-2+4*i/300
        c2=2-4*j/300
        x=c1
        y=c2
            FOR n = 1 TO 30
            x1=x*x-y*y+c1
            y1=2*x*y+c2
            r=x1*x1+y1*y1
            IF r > 4 THEN GOTO 1000
            x = x1
            y = y1
            NEXT n
        PSET(i, j)
        PSET(i,300-j)
    1000 NEXT j
NEXT i
END
Just wondered if anyone had any experience with this kinda stuff?

Edit: Thats a Mandelbrot btw.
victim is offline  
Old 20 July 2011, 03:20   #7
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 746
Wow, cheers victim, wasn't expecting an assembly example.
h0ffman is online now  
Old 20 July 2011, 18:17   #8
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
Quote:
Originally Posted by victim View Post
Here is a link to an interview with Elena Novaretti from the year 2006. The interview is very well done and also provides the mathematical foundations of fractal programming.

http://www.savage-crew.de/TA24_ElenaIview_Full.pdf


That's the interview from Total Amiga I was on about


Regards,
Lonewolf10
Lonewolf10 is offline  
Old 20 July 2011, 22:32   #9
Parsec
Registered User
 
Parsec's Avatar
 
Join Date: Feb 2003
Location: Lancashire
Age: 49
Posts: 434
I used to really like playing about with Fractint on my PC, it was a brilliant package and seemed to be thriving, but it's almost disappeared now. Still apparently available though - http://www.nahee.com/spanky/www/fractint/fractint.html
Parsec is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
What was all the fuss about fractals? Magno Boots Nostalgia & memories 15 22 June 2011 06:00

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:25.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08113 seconds with 14 queries