So basically, I wrote a little 'program' that can draw 2D fractals in Excel using VBA. Recently I tried working the de Moivre's theorem into it so that I can get different powers of Z easier. It worked, not entirely though. Here is the code.
Sub Grid()
With Range(Cells(1, 1), Cells(600, 1000))
.ColumnWidth = 0.08
.RowHeight = 0.75
.Interior.ColorIndex = 1
End With
End Sub
Sub Draw()
Dim iterCount, i, j As Double
Dim counterI, counterJ As Integer
For i = -2 To 2 Step 0.01
counterI = counterI + 1
counterJ = 0
For j = -2 To 2 Step 0.01
counterJ = counterJ + 1
iterCount = Iterate(i, j)
If iterCount > 2 Then Cells(counterI, counterJ).Interior.Color = RGB(0, 1200 / iterCount, 255)
DoEvents
Next j
Next i
End Sub
Function Iterate(ByVal j As Double, ByVal i As Double)
Dim Mag, Angle, Pi, iNew, jNew, Power As Double
If i = 0 Then Exit Function
Pi = 4 * Atn(1)
Mag = Sqr(i * i + j * j)
Angle = Atn(j / i)
Power = 4 ' <- This is the exponent
For k = 1 To 500
iNew = (Mag ^ Power) * Cos(Angle * Power) + i
jNew = (Mag ^ Power) * Sin(Angle * Power) + j
Iterate = k
If iNew = 0 Then Exit Function
Mag = Sqr(iNew * iNew + jNew * jNew)
If Mag > 2 Then Exit Function
Angle = Atn(jNew / iNew)
Next k
End Function
In case you wanted to try it out, run Grid first, then run Draw. The exponent is set to 4, you can change it to whatever.
Now the problem is that for some reason this doesn't work at all with odd exponents
When I try to render something with odd exponent, the image has weird cut-outs at top and bottom. Even exponents work just fine. If anybody could tell me why it doesn't work, that would be awesome.
I also wanted to try rendering Glynn Fractals which require fractional exponents, from what I understand though, the Formula doesn't really work with fractional exponents? What options would I have if I wanted to get that to work if any? I know VBA and Excel is not suitable for this kind of stuff at all