Welcome to Fractal Forums

Fractal Art => Images Showcase (Rate My Fractal) => Topic started by: Iariak on January 08, 2016, 09:06:06 PM




Title: Evil queen and some other fractals
Post by: Iariak on January 08, 2016, 09:06:06 PM
Queen Fractal

(http://nocache-nocookies.digitalgott.com/gallery/18/13101_08_01_16_9_06_06.jpeg)

http://www.fractalforums.com/index.php?action=gallery;sa=view;id=18558

I wanted to render a Mandelbrot Set but because I am a terrible programmer, I got this instead. Not What I wanted but still pretty cool. I did eventually figure out what I did wrong. Rendered with MS Excel  :D


Title: Re: Queen Fractal
Post by: simon.snake 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.


Title: Re: Queen Fractal
Post by: quaz0r on January 09, 2016, 06:34:26 AM
are those apostrophes?   O0


Title: Re: Queen Fractal
Post by: hermann on January 09, 2016, 07:23:21 AM
The picture looks like a julia set of tippets variation fractals!


Title: Re: Queen Fractal
Post by: Iariak 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.

Code:
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 :)


Title: Re: Queen Fractal
Post by: Iariak on January 09, 2016, 09:54:15 PM
I ended up uploading some of the pictures to flickr so I could post them here without actually uploading them here, here they are. All of these are another of my mistakes while trying to get Mandelbrot set :D
(https://farm2.staticflickr.com/1525/24277528605_6571b8609f_b.jpg) (https://flic.kr/p/CZjFrp)Urchin fractal (https://flic.kr/p/CZjFrp)
(https://farm2.staticflickr.com/1502/23649479644_31263526c8_b.jpg) (https://flic.kr/p/C2PLn3)Mandelbrot set variation (https://flic.kr/p/C2PLn3)
(https://farm2.staticflickr.com/1647/23910390269_cb6a2f210e_b.jpg) (https://flic.kr/p/CqT116)Another Fractal (https://flic.kr/p/CqT116)


Title: Re: Queen Fractal
Post by: hermann on January 10, 2016, 11:51:50 AM
Hallo,

it is possible to make a lot of variations of the basic mandelbrot algorithm.
One of your pictures looks like an Mandelbar Fractal.
An famous example is the Burning Ship fractal:
http://www.wackerart.de/burning-ship.html (http://www.wackerart.de/burning-ship.html)

For each of this kind of Fractal it is also possible to define a Julia set.

I also have made a little catalog of some fractal algorithms:
http://www.wackerart.de/fractal_catalogue.html (http://www.wackerart.de/fractal_catalogue.html)
http://www.wackerart.de/fractal_catalogue_2.html (http://www.wackerart.de/fractal_catalogue_2.html)
http://www.wackerart.de/fractal_catalogue_3.html (http://www.wackerart.de/fractal_catalogue_3.html)

How to activate the Java Applet is descript on my Java page:
http://www.wackerart.de/java.html#probleme (http://www.wackerart.de/java.html#probleme)

Hermann


Title: Re: Queen Fractal
Post by: simon.snake 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:

Code:
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


Title: Re: Queen Fractal
Post by: lycium on January 10, 2016, 01:23:16 PM
I guess the next logical step is to make a Mandelbulb path tracer in Excel  O0


Title: Re: Queen Fractal
Post by: Iariak on January 10, 2016, 01:55:53 PM
Thanks for fixing the code simon.snake, I did it slightly differently but whatever works  :D.
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 tower-like structures on top. I thought I would get that just be decreasing the number of iterations but that doesn't do it  :sad1: 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  :D
(https://farm2.staticflickr.com/1546/24185322022_8c4b3520c2_c.jpg) (https://flic.kr/p/CRb6CJ)Burning Ship at night (https://flic.kr/p/CRb6CJ)
I'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.
(https://farm2.staticflickr.com/1664/24209040862_22f057d175_c.jpg) (https://flic.kr/p/CTgEqf)Rabbit Ears (https://flic.kr/p/CTgEqf)
(https://farm2.staticflickr.com/1682/24234757881_4313676936_c.jpg) (https://flic.kr/p/CVxtc8)3 Circles (https://flic.kr/p/CVxtc8)
And 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.
(https://farm2.staticflickr.com/1449/24212714662_7445e345a8_c.jpg) (https://flic.kr/p/CTAuvC)Fireworks (https://flic.kr/p/CTAuvC)

Same fractal again, different zoom and improved coloring.
(https://farm2.staticflickr.com/1521/24256534771_966e0b0119_c.jpg) (https://flic.kr/p/CXt5GK)Radioactive weed (https://flic.kr/p/CXt5GK)
And 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.
(https://farm2.staticflickr.com/1719/24316332176_37f97ef850_c.jpg) (https://flic.kr/p/D3Kyou)More Weed (https://flic.kr/p/D3Kyou)


Title: Re: Evil queen and some other fractals
Post by: Iariak on January 13, 2016, 07:48:42 PM
I feel like this one deserves it's own post. I finally got the coloring right :D
(https://farm2.staticflickr.com/1603/24277307751_f5e4c9c126_c.jpg) (https://flic.kr/p/CZixMz)Improved Fireworks (https://flic.kr/p/CZixMz)

This queen looks even more evil...it's a zoom in of one of the fractals I posted earlier, rotated 90°.
(https://farm2.staticflickr.com/1508/24067647500_e18567afbb_c.jpg) (https://flic.kr/p/CELZ6E)Burning Queen (https://flic.kr/p/CELZ6E)


Title: Re: Evil queen and some other fractals
Post by: Ryche 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.   :hmh:

::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.


Title: Re: Evil queen and some other fractals
Post by: Iariak on January 14, 2016, 08:39:56 PM
Heh thanks, excel is really slow but it can create almost just as beautiful images as any other (2D)fractal program if you know what you're doing...Which I really don't but I'm getting there :D
* here is a better version of burning ship. Called it ghost fleet, I think it's quite appropriate :)

(https://farm2.staticflickr.com/1601/24280836831_a8efa2ce4f_c.jpg) (https://flic.kr/p/CZBCRM)Ghost Fleet (https://flic.kr/p/CZBCRM)

And one more, doing the odd/even thing again.

(https://farm2.staticflickr.com/1649/24103008450_62a5cf23f9_c.jpg) (https://flic.kr/p/CHUdFd)Trippy (https://flic.kr/p/CHUdFd)

I am such a monster...Poor Mandelbrot set :(
(https://farm2.staticflickr.com/1652/24106537380_6c23a85419_c.jpg) (https://flic.kr/p/CJdiGQ)Mangled Mandelbrot set (https://flic.kr/p/CJdiGQ)


Title: Re: Evil queen and some other fractals
Post by: simon.snake 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 re-load my attempt and have a go.


Title: Re: Evil queen and some other fractals
Post by: Iariak 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 :D But damn! Zooming in on stuff is a breeze now. Rendering is still slow but whatever :D


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
Code:
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  :o
(https://farm2.staticflickr.com/1710/24108347090_68632902e8_c.jpg) (https://flic.kr/p/CJnzEJ)Distorted fireworks (https://flic.kr/p/CJnzEJ)
(https://farm2.staticflickr.com/1530/23777171833_7098f9d685_c.jpg) (https://flic.kr/p/Ce7dNv)Fractal Dragon (https://flic.kr/p/Ce7dNv)

I did some zoom-ins 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 -.-
(https://farm2.staticflickr.com/1544/24392617836_77d5d09739_c.jpg) (https://flic.kr/p/Dauxsu)Vortex (https://flic.kr/p/Dauxsu)
(https://farm2.staticflickr.com/1638/24123285150_8ce8d7483c_c.jpg) (https://flic.kr/p/CKG9eu)Another Zoom into Mandelbrot (https://flic.kr/p/CKG9eu)

Burning Ship is awesome!
(https://farm2.staticflickr.com/1519/23797776613_f917ee2c5d_c.jpg) (https://flic.kr/p/CfVPTk)Golden Cage (https://flic.kr/p/CfVPTk)
(https://farm2.staticflickr.com/1653/24359389141_5fcb3b3844_c.jpg) (https://flic.kr/p/D7yeHX)Golden Cage Nr. 2 (https://flic.kr/p/D7yeHX)

This 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.

(https://farm2.staticflickr.com/1603/24379574881_9ea825ed81_c.jpg) (https://flic.kr/p/D9kGeX)Space Octopus (https://flic.kr/p/D9kGeX)
*I animated it :P This is how the fractal reacts to adding small portions of |c| every iteration.
(https://farm2.staticflickr.com/1654/23835701124_2a820facd6_o.gif) (https://flic.kr/p/Cjhcwd)Animated Space Octopus (https://flic.kr/p/Cjhcwd)


Title: Re: Evil queen and some other fractals
Post by: kaludix on February 07, 2016, 08:26:29 AM
I played with the corrected Mandelbrot code and have two small mods that will decrease execution time by more than 4X.

(1) Data types need to be specified for each variable.  The line...
Dim i, j As Double
will define i as a Variant data type and j as a Double.  Variants are more expensive than Doubles.  This line and all lines like it should be in the form...
Dim i As Double, j As Double

(2) Using DoEvents is expensive and updating the screen is very expensive in Excel.  I modified the code to turn off the screen updating and inform the user of progress every 1% using the status bar.

Code:
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 As Double, jen As Double, ienz As Double, jenz As Double
Dim xmag As Double, 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 As Integer, pocitadloj As Integer
Dim i As Double, j As Double
Dim oldStatusBar As Boolean, k As Integer, numRows As Integer
'Dim timerStart As Single

' Initial application controls
'timerStart = Timer
With Application
    .ScreenUpdating = False
    oldStatusBar = .DisplayStatusBar
    .DisplayStatusBar = True
    .StatusBar = "Starting..."
End With

' pro mandelbrotovu mnozinu i od -1 do 1, j od -2 do 1
numRows = Int((2 - (-2)) / 0.003) + 1
For i = -2 To 2 Step 0.003
    k = k + 1
    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
    Next j
    If k Mod Int(numRows / 100) = 0 Then
        DoEvents  'prevents status bar from freezing during execution
        Application.StatusBar = "Calculating/Outputting... " & Round((k / numRows) * 100, 0) & "%"
    End If
Next i

' Ending application controls
With Application
    .StatusBar = False
    .DisplayStatusBar = oldStatusBar
    .ScreenUpdating = True
End With
'MsgBox Round(Timer - timerStart, 2) & " seconds"
End Sub


Title: Re: Evil queen and some other fractals
Post by: Iariak on March 22, 2016, 08:40:12 PM
Hey thanks for that! I thought "dim i, j as double" defines both as double, shows what I know   :-X I've also never used nor heard of status bar, it looks pretty useful.


Title: Re: Evil queen and some other fractals
Post by: simon.snake on March 23, 2016, 12:17:58 AM
Another minor change to the code rotates the fractal the 'right way around' and makes the colours more interesting.

I cannot upload a copy of the resultant image but I hope it is worth it.

Enjoy.

Code:
Sub Grid()
With Range(Cells(1, 1), Cells(1900, 1900))
    .ColumnWidth = 0.08
    .RowHeight = 0.75
    .Interior.Color = 16777215
End With
End Sub
'----------------------------------------------------
Function iterateQueen(ByVal i As Double, j As Double)
Dim ien As Double, jen As Double, ienz As Double, jenz As Double
Dim xmag As Double, 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 = k
        Exit For
    End If
Next k
iterateQueen = patri
End Function
'----------------------------------------------------
Sub drawMandelbrot()
Dim pocitadloi As Integer, pocitadloj As Integer
Dim i As Double, j As Double
Dim oldStatusBar As Boolean, k As Integer, numRows As Integer
'Dim timerStart As Single

' Initial application controls
'timerStart = Timer
With Application
    .ScreenUpdating = False
    oldStatusBar = .DisplayStatusBar
    .DisplayStatusBar = True
    .StatusBar = "Starting..."
End With

' pro mandelbrotovu mnozinu i od -1 do 1, j od -2 do 1
numRows = Int((2 - (-2)) / 0.003) + 1
For i = -2 To 2 Step 0.003
    k = k + 1
    pocitadloi = pocitadloi + 1
    pocitadloj = 0
    For j = -1.5 To 1.5 Step 0.003
        pocitadloj = pocitadloj + 1
        Cells(pocitadloj, pocitadloi).Interior.Color = iterateQueen(i, j)
    Next j
    If k Mod Int(numRows / 100) = 0 Then
        DoEvents  'prevents status bar from freezing during execution
        Application.StatusBar = "Calculating/Outputting... " & Round((k / numRows) * 100, 0) & "%"
    End If
Next i

' Ending application controls
With Application
    .StatusBar = False
    .DisplayStatusBar = oldStatusBar
    .ScreenUpdating = True
End With
'MsgBox Round(Timer - timerStart, 2) & " seconds"
End Sub