
simon.snake
Fractal Bachius
Posts: 640
Experienced Fractal eXtreme plugin crasher!


« Reply #1 on: January 08, 2016, 11:54:24 PM » 

How does one render a fractal in MS Excel?
Ok, I know it's Visual Basic, but do you use the cells to calculate values and then plot them into a graph, or what???
Haven't played with VB inside Excel for a good number of years.



Logged

To anyone viewing my posts and finding missing/broken links to a website called www.needanother.co.uk, I still own the domain but recently cancelled my server (saving £30/month) so even though the domain address exists, it points nowhere. I hope to one day sort something out but for now  sorry!



quaz0r
Fractal Molossus
Posts: 652


« Reply #2 on: January 09, 2016, 06:34:26 AM » 

are those apostrophes?



Logged




hermann
Iterator
Posts: 181


« Reply #3 on: January 09, 2016, 07:23:21 AM » 

The picture looks like a julia set of tippets variation fractals!



Logged




Iariak


« Reply #4 on: January 09, 2016, 09:20:32 AM » 

How does one render a fractal in MS Excel?
Ok, I know it's Visual Basic, but do you use the cells to calculate values and then plot them into a graph, or what???
Haven't played with VB inside Excel for a good number of years.
OK I hope this is not against some kinda rules here but I will post the code so you can try rendering it yourself Just post this into the VBA editor, first run Grid, this will reduce the size of the cells to 1x1 pixel. Then run drawMandelbrot. It may take a while to render, depending on how fast your PC is. Sub Grid() With Range(Cells(1, 1), Cells(1900, 1900)) .ColumnWidth = 0.08 .RowHeight = 0.75 End With End Sub Function iterateQueen(ByVal i As Double, j As Double) Dim ien, jen, ienz, jenz, mag As Double Dim patri As Integer ien = i * i  j * j jen = 2 * i * j patri = 1 For k = 1 To 1000 ien = ien * ien  jen * jen + i jen = 2 * ien * jen + j mag = Sqr(ien * ien + jen * jen) If mag > 2 Then patri = 0 Exit For End If Next k iterateQueen = patri End Function Sub drawMandelbrot() Dim pocitadloi, pocitadloj As Integer Dim i, j As Double ' pro mandelbrotovu mnozinu i od 1 do 1, j od 2 do 1 For i = 2 To 2 Step 0.003 pocitadloi = pocitadloi + 1 pocitadloj = 0 For j = 1 To 1 Step 0.003 pocitadloj = pocitadloj + 1 If iterateQueen(i, j) = 1 Then Cells(pocitadloi, pocitadloj).Interior.ColorIndex = 3 DoEvents Next j Next i End Sub
After this, I managed to fix the code so that it actually draws a Mandelbrot Set. I also tried making some more deliberate 'mistakes' in the iterate function and I got a bunch more different fractals which I would like to post. Some of them look even cooler than this one. By the way, would there be a way to upload an image and post it in this thread without creating another one? Because I thought that when I upload an image to a gallery, I would have to make my own thread in this section of the forums and link it but it turns out the thread is created automatically. Thanks


« Last Edit: January 10, 2016, 01:10:19 PM by Iariak »

Logged




Iariak


« Reply #5 on: January 09, 2016, 09:54:15 PM » 



« Last Edit: January 09, 2016, 10:21:04 PM by Iariak »

Logged





simon.snake
Fractal Bachius
Posts: 640
Experienced Fractal eXtreme plugin crasher!


« Reply #7 on: January 10, 2016, 12:10:14 PM » 

For anyone who hasn't managed to get it working, here's the corrected code to make a mandelbrot: Sub Grid() With Range(Cells(1, 1), Cells(1900, 1900)) .ColumnWidth = 0.08 .RowHeight = 0.75 End With End Sub
Function iterateQueen(ByVal i As Double, j As Double) Dim ien, jen, ienz, jenz, xmag, ymag As Double Dim patri As Integer xmag = i * i ymag = j * j ien = i jen = j patri = 1 For k = 1 To 1000 jen = 2 * ien * jen + j ien = xmag  ymag + i xmag = ien * ien ymag = jen * jen If xmag + ymag > 4 Then patri = 0 Exit For End If Next k iterateQueen = patri End Function
Sub drawMandelbrot() Dim pocitadloi, pocitadloj As Integer Dim i, j As Double ' pro mandelbrotovu mnozinu i od 1 do 1, j od 2 do 1 For i = 2 To 2 Step 0.003 pocitadloi = pocitadloi + 1 pocitadloj = 0 For j = 1 To 1 Step 0.003 pocitadloj = pocitadloj + 1 If iterateQueen(i, j) = 1 Then Cells(pocitadloi, pocitadloj).Interior.ColorIndex = 3 DoEvents Next j Next i End Sub



Logged

To anyone viewing my posts and finding missing/broken links to a website called www.needanother.co.uk, I still own the domain but recently cancelled my server (saving £30/month) so even though the domain address exists, it points nowhere. I hope to one day sort something out but for now  sorry!



lycium


« Reply #8 on: January 10, 2016, 01:23:16 PM » 

I guess the next logical step is to make a Mandelbulb path tracer in Excel



Logged




Iariak


« Reply #9 on: January 10, 2016, 01:55:53 PM » 

Thanks for fixing the code simon.snake, I did it slightly differently but whatever works . Also thanks for the links hermann, Burning ship looks absolutely incredible! I gotta try to render that myself. edit: K so I managed to render Burning ship, although I don't have those cool towerlike structures on top. I thought I would get that just be decreasing the number of iterations but that doesn't do it How do you get those structures? edit again: Got it, I just needed to zoom in to another area And here it is, again rendered using VBA in Excel. I LOVE this one, my favourite so far thanks so much for the links again Hermann Burning Ship at nightI'll add some more that I discovered today, one is a zoom in of a fractal with very similar formula as Mandelbrot set. In fact, it's the same formula only the first iteration is changed slightly. And the other one is the same formula as the concentric circle thing only, again, the first iteration is changed. It's really quite interesting that by changing the first iteration you get a drastically different results. Rabbit Ears3 CirclesAnd one more, this is the same fractal as the 'rabbit ears', just different coordinates and different zoom. You can actually see this area on the upper picture in the top left corner. FireworksSame fractal again, different zoom and improved coloring. Radioactive weedAnd here is some more weed...I experimented a little bit with the one on the left. Only points that diverge after even number of iterations are rendered. Points that never diverge are not rendered at all. More Weed


« Last Edit: January 12, 2016, 10:35:21 PM by Iariak »

Logged





Ryche


« Reply #11 on: January 14, 2016, 08:32:46 PM » 

Very nice work on the Red Queens & everything here.. I'm going to simply ignore the fact that youre doing all this in Excel. That is beyond my comprehension. ::edit: actually ive done a decent amount of work on VB. and i know a fair bit of coding in Javascript & Processing. But still.................... My head explodes just thinking about doing fractals in Excel.



Logged





simon.snake
Fractal Bachius
Posts: 640
Experienced Fractal eXtreme plugin crasher!


« Reply #13 on: January 15, 2016, 11:33:32 PM » 

I'd love to see a zoomed image of the bottom middle section of that mangled mandelbrot (the bottom picture in your latest reply). It almost resembles a pair of front legs.
Also, I guess it is possible to allow the user to select a range of cells and then use the coordinates they represent for the next zoomed image, but how would you achieve that within Excel? I guess a new toolbar with a button on it which calls the appropriate macro?
Might have to reload my attempt and have a go.



Logged

To anyone viewing my posts and finding missing/broken links to a website called www.needanother.co.uk, I still own the domain but recently cancelled my server (saving £30/month) so even though the domain address exists, it points nowhere. I hope to one day sort something out but for now  sorry!



Iariak


« Reply #14 on: January 16, 2016, 12:51:07 AM » 

Yea zooming in the way I do it now is incredible pain, it's basically trial and error where I play with the coordinates trying to find the area I want. It would be possible to save the initial area and zoom that you render, then select an area and recalculate new coordinates and zoom for that area. The problem is that you would have to store the values somewhere...cells seem good at first glance but from what I understand, excel only counts first 15 decimal places so you would run out of space rather quickly. Now that I think about it though, it might be possible to store the values in a text file and read them from there, I might try to do that. Edit: Storing the values in a text file works, but it's kinda pointless because it doesn't display more than 15 decimal places either way so storing them in cells would probably make more sense But damn! Zooming in on stuff is a breeze now. Rendering is still slow but whatever I was also wondering if it was possible to speed up the rendering somehow. It might be possible to make a huge variant array that represents the rendered area and store the iteration count for each pixel there, then assign that array to a range of cells and use conditional formatting to actually visualize the image. Getting into each cell and coloring it one by one is what takes most time. Not sure if you could get the coloring flexibility I have now that way though. * If you like, you can try finding that area yourself. Here is the code for the mangled mandelbrot set. Zoomed in on that black hole thingy Sub drawMNoAxis() Dim pocitadloi, pocitadloj, iterate As Integer Dim i, j As Double
' pro mandelbrotovu mnozinu i od 1 do 1, j od 2 do 1 For i = 0.45 To 0.4 Step 0.00006 pocitadloi = pocitadloi + 1 pocitadloj = 0 For j = 0.32 To 0.38 Step 0.00006 pocitadloj = pocitadloj + 1 iterate = iterateM22(i, j) If iterate > 20 Then Cells(pocitadloi, pocitadloj).Interior.Color = RGB((iterate  5) * 5, iterate, 255 / iterate) DoEvents Next j Next i
End Sub Function iterateM22(ByVal j As Double, i As Double) Dim ien, jen, ienz, jenz, mag As Double Dim patri As Integer
ien = i * i  j * j + i ien = Sqr(Abs(ien)) jen = 2 * i * j + j jen = Sqr(Abs(jen)) ienz = ien jenz = jen patri = 1
For k = 1 To 1000 ien = ienz * ienz  (jenz * jenz) + i jen = 2 * ienz * jenz + j ienz = ien jenz = jen mag = Sqr(ien * ien + jen * jen) If mag > 2 Then patri = k Exit For End If patri = k Next k iterateM22 = patri End Function
Oh and I did 2 zooms of the weird mandelbrot set, one of them looks like a dragon and the other one looks almost like the fractal is getting sucked into a black hole or something Distorted fireworksFractal DragonI did some zoomins with my improved "program", one is Mandelbrot set and the other one is the same fractal as the Weed pictures. The mandelbrot one took over half an hour to render, no jokes . VortexAnother Zoom into MandelbrotBurning Ship is awesome! Golden CageGolden Cage Nr. 2This is an interesting one...While browsing these forums I found a picture of a fractal where the description said they used log during the iteration. I tried natural log (because apparently VBA can't do any other? ) And found this one. The smaller one in top left is just the big one, zoomed out. Space Octopus*I animated it This is how the fractal reacts to adding small portions of c every iteration. Animated Space Octopus


« Last Edit: January 18, 2016, 07:25:53 PM by Iariak »

Logged




