Home » Archimedes archive » Acorn Computing » 1993 09 Mega Disk.adf » 93_09 » Miscellany/!4dMandia/docums/4dFractals
Miscellany/!4dMandia/docums/4dFractals
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn Computing » 1993 09 Mega Disk.adf » 93_09 |
Filename: | Miscellany/!4dMandia/docums/4dFractals |
Read OK: | ✔ |
File size: | 073B bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
4D FRACTALS I am getting VERY bored typing all these instructions (this is the last), so I shall only be brief in describing what 4 dimensional fractals are: The four dimensional fractal that I use is a variation on the 2 dimensional complex number. The 4d equivalent is known as the Quaternion; invented by William Hamilton, 1843. (Legend has it that he was so chuffed with what he had created that he carved the equation onto a stone bridge in wales.) He was, in fact, looking for a 3d complex number but to make it work it had to be 4 dimensional. Written as: Q = a+bi+cj+dk where i, j and k are imaginary numbers. The routine below is the normal squaring and adding a constant used for Julia and Mandlebrot sets. But it is four dimensional. It maps out a two dimensional slice using x=a and y=c, with the values of b and d being set to choose which slice of the 4d plane to draw. The initial values chosen for q0 and q2 are the same as those for the Julia Set, and you will note the image is superficially very similar. Changing q1, q3, b or d however allows different planes to be examined, giving a great area to investigate. As with the Julia set, the best way to choose nice sets is from the Mandlebrot set. Normally you would choose q0 and q2, but my program chooses q0 and q1. It is the same result. Changing q2, q3, b or d allows different planes to be examined. For each pixel, you calculate the a (x) and c (y) value and then iterate. The colour is set to the iteration number unless a limit of Q� is more than 4. In my program it is 2... I think! iterations=max_no_iterations REPEAT size=(a�+b�+c�+d�) new_a=a�-b�-c�-d�+q0 b=2*a*b+q1 c=2*a*c+q2 d=2*a*d+q3 a=new_a iterations-=1 UNTIL iterations=0 OR size>4 My program can also iterate the function Mandlebrot style which gives a variation on the Mandlebrot shape.
00000000 34 44 20 46 52 41 43 54 41 4c 53 0a 0a 0a 49 20 |4D FRACTALS...I | 00000010 61 6d 20 67 65 74 74 69 6e 67 20 56 45 52 59 20 |am getting VERY | 00000020 62 6f 72 65 64 20 74 79 70 69 6e 67 20 61 6c 6c |bored typing all| 00000030 20 74 68 65 73 65 20 69 6e 73 74 72 75 63 74 69 | these instructi| 00000040 6f 6e 73 20 28 74 68 69 73 20 69 73 20 74 68 65 |ons (this is the| 00000050 20 6c 61 73 74 29 2c 20 73 6f 0a 49 20 73 68 61 | last), so.I sha| 00000060 6c 6c 20 6f 6e 6c 79 20 62 65 20 62 72 69 65 66 |ll only be brief| 00000070 20 69 6e 20 64 65 73 63 72 69 62 69 6e 67 20 77 | in describing w| 00000080 68 61 74 20 34 20 64 69 6d 65 6e 73 69 6f 6e 61 |hat 4 dimensiona| 00000090 6c 20 66 72 61 63 74 61 6c 73 20 61 72 65 3a 0a |l fractals are:.| 000000a0 0a 0a 0a 54 68 65 20 66 6f 75 72 20 64 69 6d 65 |...The four dime| 000000b0 6e 73 69 6f 6e 61 6c 20 66 72 61 63 74 61 6c 20 |nsional fractal | 000000c0 74 68 61 74 20 49 20 75 73 65 20 69 73 20 61 20 |that I use is a | 000000d0 76 61 72 69 61 74 69 6f 6e 20 6f 6e 20 74 68 65 |variation on the| 000000e0 20 32 20 64 69 6d 65 6e 73 69 6f 6e 61 6c 0a 63 | 2 dimensional.c| 000000f0 6f 6d 70 6c 65 78 20 6e 75 6d 62 65 72 2e 20 54 |omplex number. T| 00000100 68 65 20 34 64 20 65 71 75 69 76 61 6c 65 6e 74 |he 4d equivalent| 00000110 20 69 73 20 6b 6e 6f 77 6e 20 61 73 20 74 68 65 | is known as the| 00000120 20 51 75 61 74 65 72 6e 69 6f 6e 3b 20 69 6e 76 | Quaternion; inv| 00000130 65 6e 74 65 64 20 62 79 0a 57 69 6c 6c 69 61 6d |ented by.William| 00000140 20 48 61 6d 69 6c 74 6f 6e 2c 20 31 38 34 33 2e | Hamilton, 1843.| 00000150 20 28 4c 65 67 65 6e 64 20 68 61 73 20 69 74 20 | (Legend has it | 00000160 74 68 61 74 20 68 65 20 77 61 73 20 73 6f 20 63 |that he was so c| 00000170 68 75 66 66 65 64 20 77 69 74 68 20 77 68 61 74 |huffed with what| 00000180 20 68 65 0a 68 61 64 20 63 72 65 61 74 65 64 20 | he.had created | 00000190 74 68 61 74 20 68 65 20 63 61 72 76 65 64 20 74 |that he carved t| 000001a0 68 65 20 65 71 75 61 74 69 6f 6e 20 6f 6e 74 6f |he equation onto| 000001b0 20 61 20 73 74 6f 6e 65 20 62 72 69 64 67 65 20 | a stone bridge | 000001c0 69 6e 20 77 61 6c 65 73 2e 29 20 48 65 0a 77 61 |in wales.) He.wa| 000001d0 73 2c 20 69 6e 20 66 61 63 74 2c 20 6c 6f 6f 6b |s, in fact, look| 000001e0 69 6e 67 20 66 6f 72 20 61 20 33 64 20 63 6f 6d |ing for a 3d com| 000001f0 70 6c 65 78 20 6e 75 6d 62 65 72 20 62 75 74 20 |plex number but | 00000200 74 6f 20 6d 61 6b 65 20 69 74 20 77 6f 72 6b 20 |to make it work | 00000210 69 74 20 68 61 64 20 74 6f 0a 62 65 20 34 20 64 |it had to.be 4 d| 00000220 69 6d 65 6e 73 69 6f 6e 61 6c 2e 20 57 72 69 74 |imensional. Writ| 00000230 74 65 6e 20 61 73 3a 0a 0a 51 20 3d 20 61 2b 62 |ten as:..Q = a+b| 00000240 69 2b 63 6a 2b 64 6b 20 77 68 65 72 65 20 69 2c |i+cj+dk where i,| 00000250 20 6a 20 61 6e 64 20 6b 20 61 72 65 20 69 6d 61 | j and k are ima| 00000260 67 69 6e 61 72 79 20 6e 75 6d 62 65 72 73 2e 0a |ginary numbers..| 00000270 0a 54 68 65 20 72 6f 75 74 69 6e 65 20 62 65 6c |.The routine bel| 00000280 6f 77 20 69 73 20 74 68 65 20 6e 6f 72 6d 61 6c |ow is the normal| 00000290 20 73 71 75 61 72 69 6e 67 20 61 6e 64 20 61 64 | squaring and ad| 000002a0 64 69 6e 67 20 61 20 63 6f 6e 73 74 61 6e 74 20 |ding a constant | 000002b0 75 73 65 64 20 66 6f 72 0a 4a 75 6c 69 61 20 61 |used for.Julia a| 000002c0 6e 64 20 4d 61 6e 64 6c 65 62 72 6f 74 20 73 65 |nd Mandlebrot se| 000002d0 74 73 2e 20 42 75 74 20 69 74 20 69 73 20 66 6f |ts. But it is fo| 000002e0 75 72 20 64 69 6d 65 6e 73 69 6f 6e 61 6c 2e 20 |ur dimensional. | 000002f0 49 74 20 6d 61 70 73 20 6f 75 74 20 61 20 74 77 |It maps out a tw| 00000300 6f 0a 64 69 6d 65 6e 73 69 6f 6e 61 6c 20 73 6c |o.dimensional sl| 00000310 69 63 65 20 75 73 69 6e 67 20 78 3d 61 20 61 6e |ice using x=a an| 00000320 64 20 79 3d 63 2c 20 77 69 74 68 20 74 68 65 20 |d y=c, with the | 00000330 76 61 6c 75 65 73 20 6f 66 20 62 20 61 6e 64 20 |values of b and | 00000340 64 20 62 65 69 6e 67 20 73 65 74 20 74 6f 0a 63 |d being set to.c| 00000350 68 6f 6f 73 65 20 77 68 69 63 68 20 73 6c 69 63 |hoose which slic| 00000360 65 20 6f 66 20 74 68 65 20 34 64 20 70 6c 61 6e |e of the 4d plan| 00000370 65 20 74 6f 20 64 72 61 77 2e 0a 54 68 65 20 69 |e to draw..The i| 00000380 6e 69 74 69 61 6c 20 76 61 6c 75 65 73 20 63 68 |nitial values ch| 00000390 6f 73 65 6e 20 66 6f 72 20 71 30 20 61 6e 64 20 |osen for q0 and | 000003a0 71 32 20 61 72 65 20 74 68 65 20 73 61 6d 65 20 |q2 are the same | 000003b0 61 73 20 74 68 6f 73 65 20 66 6f 72 20 74 68 65 |as those for the| 000003c0 20 4a 75 6c 69 61 0a 53 65 74 2c 20 61 6e 64 20 | Julia.Set, and | 000003d0 79 6f 75 20 77 69 6c 6c 20 6e 6f 74 65 20 74 68 |you will note th| 000003e0 65 20 69 6d 61 67 65 20 69 73 20 73 75 70 65 72 |e image is super| 000003f0 66 69 63 69 61 6c 6c 79 20 76 65 72 79 20 73 69 |ficially very si| 00000400 6d 69 6c 61 72 2e 20 43 68 61 6e 67 69 6e 67 20 |milar. Changing | 00000410 71 31 2c 0a 71 33 2c 20 62 20 6f 72 20 64 20 68 |q1,.q3, b or d h| 00000420 6f 77 65 76 65 72 20 61 6c 6c 6f 77 73 20 64 69 |owever allows di| 00000430 66 66 65 72 65 6e 74 20 70 6c 61 6e 65 73 20 74 |fferent planes t| 00000440 6f 20 62 65 20 65 78 61 6d 69 6e 65 64 2c 20 67 |o be examined, g| 00000450 69 76 69 6e 67 20 61 20 67 72 65 61 74 0a 61 72 |iving a great.ar| 00000460 65 61 20 74 6f 20 69 6e 76 65 73 74 69 67 61 74 |ea to investigat| 00000470 65 2e 0a 41 73 20 77 69 74 68 20 74 68 65 20 4a |e..As with the J| 00000480 75 6c 69 61 20 73 65 74 2c 20 74 68 65 20 62 65 |ulia set, the be| 00000490 73 74 20 77 61 79 20 74 6f 20 63 68 6f 6f 73 65 |st way to choose| 000004a0 20 6e 69 63 65 20 73 65 74 73 20 69 73 20 66 72 | nice sets is fr| 000004b0 6f 6d 20 74 68 65 0a 4d 61 6e 64 6c 65 62 72 6f |om the.Mandlebro| 000004c0 74 20 73 65 74 2e 20 4e 6f 72 6d 61 6c 6c 79 20 |t set. Normally | 000004d0 79 6f 75 20 77 6f 75 6c 64 20 63 68 6f 6f 73 65 |you would choose| 000004e0 20 71 30 20 61 6e 64 20 71 32 2c 20 62 75 74 20 | q0 and q2, but | 000004f0 6d 79 20 70 72 6f 67 72 61 6d 20 63 68 6f 6f 73 |my program choos| 00000500 65 73 0a 71 30 20 61 6e 64 20 71 31 2e 20 49 74 |es.q0 and q1. It| 00000510 20 69 73 20 74 68 65 20 73 61 6d 65 20 72 65 73 | is the same res| 00000520 75 6c 74 2e 20 43 68 61 6e 67 69 6e 67 20 20 71 |ult. Changing q| 00000530 32 2c 20 71 33 2c 20 62 20 6f 72 20 64 20 61 6c |2, q3, b or d al| 00000540 6c 6f 77 73 20 64 69 66 66 65 72 65 6e 74 0a 70 |lows different.p| 00000550 6c 61 6e 65 73 20 74 6f 20 62 65 20 65 78 61 6d |lanes to be exam| 00000560 69 6e 65 64 2e 0a 0a 46 6f 72 20 65 61 63 68 20 |ined...For each | 00000570 70 69 78 65 6c 2c 20 79 6f 75 20 63 61 6c 63 75 |pixel, you calcu| 00000580 6c 61 74 65 20 74 68 65 20 61 20 28 78 29 20 61 |late the a (x) a| 00000590 6e 64 20 63 20 28 79 29 20 76 61 6c 75 65 20 61 |nd c (y) value a| 000005a0 6e 64 20 74 68 65 6e 20 69 74 65 72 61 74 65 2e |nd then iterate.| 000005b0 0a 54 68 65 20 63 6f 6c 6f 75 72 20 69 73 20 73 |.The colour is s| 000005c0 65 74 20 74 6f 20 74 68 65 20 69 74 65 72 61 74 |et to the iterat| 000005d0 69 6f 6e 20 6e 75 6d 62 65 72 20 75 6e 6c 65 73 |ion number unles| 000005e0 73 20 61 20 6c 69 6d 69 74 20 6f 66 20 51 b2 20 |s a limit of Q. | 000005f0 69 73 20 6d 6f 72 65 20 74 68 61 6e 0a 34 2e 20 |is more than.4. | 00000600 49 6e 20 6d 79 20 70 72 6f 67 72 61 6d 20 69 74 |In my program it| 00000610 20 69 73 20 32 2e 2e 2e 20 49 20 74 68 69 6e 6b | is 2... I think| 00000620 21 0a 0a 69 74 65 72 61 74 69 6f 6e 73 3d 6d 61 |!..iterations=ma| 00000630 78 5f 6e 6f 5f 69 74 65 72 61 74 69 6f 6e 73 0a |x_no_iterations.| 00000640 52 45 50 45 41 54 0a 20 20 73 69 7a 65 3d 28 61 |REPEAT. size=(a| 00000650 b2 2b 62 b2 2b 63 b2 2b 64 b2 29 0a 20 20 6e 65 |.+b.+c.+d.). ne| 00000660 77 5f 61 3d 61 b2 2d 62 b2 2d 63 b2 2d 64 b2 2b |w_a=a.-b.-c.-d.+| 00000670 71 30 0a 20 20 62 3d 32 2a 61 2a 62 2b 71 31 0a |q0. b=2*a*b+q1.| 00000680 20 20 63 3d 32 2a 61 2a 63 2b 71 32 0a 20 20 64 | c=2*a*c+q2. d| 00000690 3d 32 2a 61 2a 64 2b 71 33 0a 20 20 61 3d 6e 65 |=2*a*d+q3. a=ne| 000006a0 77 5f 61 0a 69 74 65 72 61 74 69 6f 6e 73 2d 3d |w_a.iterations-=| 000006b0 31 0a 55 4e 54 49 4c 20 69 74 65 72 61 74 69 6f |1.UNTIL iteratio| 000006c0 6e 73 3d 30 20 4f 52 20 73 69 7a 65 3e 34 0a 0a |ns=0 OR size>4..| 000006d0 4d 79 20 70 72 6f 67 72 61 6d 20 63 61 6e 20 61 |My program can a| 000006e0 6c 73 6f 20 69 74 65 72 61 74 65 20 74 68 65 20 |lso iterate the | 000006f0 66 75 6e 63 74 69 6f 6e 20 4d 61 6e 64 6c 65 62 |function Mandleb| 00000700 72 6f 74 20 73 74 79 6c 65 20 77 68 69 63 68 20 |rot style which | 00000710 67 69 76 65 73 20 61 0a 76 61 72 69 61 74 69 6f |gives a.variatio| 00000720 6e 20 6f 6e 20 74 68 65 20 4d 61 6e 64 6c 65 62 |n on the Mandleb| 00000730 72 6f 74 20 73 68 61 70 65 2e 0a |rot shape..| 0000073b