Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ut-emx!walt.cc.utexas.edu!jkuhn From: jkuhn@walt.cc.utexas.edu (Jeff Kuhn) Newsgroups: comp.sys.handhelds Subject: Mandelbrot Sets (Fractals) on your HP48SX Message-ID: <27947@ut-emx.UUCP> Date: 10 Apr 90 22:36:22 GMT Sender: news@ut-emx.UUCP Reply-To: jkuhn@walt.cc.utexas.edu (Jeff Kuhn) Organization: The University of Texas at Austin, Austin, Texas Lines: 171 I bought an HP48SX about 2 weeks ago and have had a hard time putting it down. Here is my first offering to the net: a Mandelbrot set plotter. ------------------------------------------------------------------------------- MAND ---- OVERVIEW -------- MAND uses the truth plotting capabilities of the HP48SX to generate a plot of the Mandelbrot set. These plots take about five or six hours to generate, but the results are interresting. Be patient. USAGE ----- Place this program in its own directory. Press {MAND} to get a list of options. {SAVE} Prompts for a name to save the current plot and plotting parameters. {LOAD} Prompts for a name to load a previous plot. {EDIT} Brings up the plotting sub-menu. Press [Orange-Shift] [REVIEW] to display the current plotting parameters. Press [Orange- Shift] [GRAPH] to zoom in. {NEW} Resets the plotting parameters to display the entire set {ITTER} Prompts for the number of itterations to use in the calculation. {QUIT} Return to the variable menu. -------------------------------- cut here ------------------------------------ %%HP: T(3)A(R)F(.); DIR MAND @ Set up the custom menu for the mandelbrot set program @ Check: # 54125d Bytes: 293 \<< { { "SAVE" {SAVE } } { "LOAD" {LOAD } } { "EDIT" { \<< 33 MENU PICT RCL \->LCD 3 FREEZE \>> } } { "NEW" { \<< DEFAULTppar 'PPAR' STO 100 'nITTR' STO 33 MENU \>> } } { "ITTER" { ITTER } } { "QUIT" { \<< 0 MENU \>> } } } TMENU \>> SAVE @ Saves a graphical image allong with it's plotting parameters @ Check: # 58326d Bytes: 77 \<< "Enter name to save as" "" INPUT OBJ\-> PICT RCL PPAR 2 \->LIST SWAP STO \>> LOAD @ Loads a graphical image into PICT and sets the current plotting parameters @ Check: # 19949d Bytes: 102.5 \<< "Enter Picture to load" "" INPUT OBJ\-> OBJ\-> DROP 'PPAR' STO DUP PICT STO \->LCD 3 FREEZE 33 MENU \>> ITTER @ prompts for number of itterations @ Check: # 13905d Bytes: 77.5 \<< "Enter number of itterations" "" INPUT OBJ\-> 'nITTR' STO \>> Q MANDGEN MANDGEN @ Generates a TRUE (1) or FALSE (0) for a single pixel based on the number @ of itterations it took in the Z=Z^2+C calculation, and the dither pattern. @ Check: # 19488d Bytes: 132 \<< X Y R\->C nITTR ITR nITTR / IF DUP 1 == THEN DROP 1 ELSE 16 * 4 MOD IP X Y R\->C DITH? END \>> DEFAULTppar @ Check # 54257d Bytes: 90 { (-1.5,-1) (1.5,1) X 0 (100,100) TRUTH Y } PPAR @ Check # 4776d Bytes: 83 { (-1.5,-1) (1.5,1) X 0 (100,100) TRUTH Y } @ The current number of itterations nITTR 50 DITH? @ takes a color (from 0 to 4) and a point (in complex coords) from the stack @ and returns a 1 or 0 if that pixel should be set. @ Check: # 55653d Bytes: 108 \<< C\->PX OBJ\-> DROP B\->R SWAP B\->R \-> c x y \<< PAT c 1 + GET y 2 MOD 1 + GET x 2 MOD 1 + GET \>> \>> PAT @ 4x4 dither patterns @ 00 10 10 11 11 @ 00 00 01 01 11 @ Check: # 26668d Bytes: 137.5 { { { 0 0 } { 0 0 } } { { 1 0 } { 0 0 } } { { 1 0 } { 0 1 } } { { 1 1 } { 0 1 } } { { 1 1 } { 1 1 } } } ITR @ takes a complex point and the number of itterations and performs the @ Z = Z^2 + C calculation @ Check: # 15058d Bytes 149.5 \<< 0 \-> c itter i \<< c PIXON c PIXOFF (0,0) DO DUP * c + 'i' INCR UNTIL itter > OVER C\->R * ABS 4 > OR END DROP i 1 - \>> \>> END