Julia Set

The filled Julia set is similar to the Mandelbrot set, but instead of changing the c value within the function z^2 + c, the first iterant value is changed from 0, to the particular point on the complex plane. This allows for a fixed c value and a range of different pictures.

Creation of this visualisation was comparatively simple, as the complex number function from Mandelbrot could be reused and applied to a new iteration of the visualisation. The difficulty in making this however, was in picking the correct c value and artifically colouring the resultant picture.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Module JuliaSet
    Sub Main()
        Using BMP As New Drawing.Bitmap(5000, 5000), bmpgraphics = Drawing.Graphics.FromImage(BMP)
            For i = 0 To 5000 - 1
                For j = 0 To 5000 - 1
                    Dim Real As Double = 0.0008 * i - 2
                    Dim Complex As Double = 0.0008 * j - 2
                    Dim Properties As Escape = Escapes(New ComplexNumber(Real, Complex))

                    'Plot point if it has escaped
                    If Properties.Escaped = True Then BMP.SetPixel(i, j, New HSBColour(-3.5 * Math.Sqrt(Properties.Iterations) + 30, 1, 1).HSBToRGB)
                Next
            Next

            BMP.Save("FilledJulia.bmp", Drawing.Imaging.ImageFormat.Bmp)
        End Using
    End Sub

    Function Escapes(Current As ComplexNumber) As Escape
        ' z^2 + c
        Dim C As New ComplexNumber(-0.1259259, -0.7851851)
        'Fixed C Value
        Dim PreviousValues As New System.Collections.Generic.List(Of ComplexNumber)

        For iterations = 0 To 1000
            '1000 iterations
            Current = Current.Squared.Add(C)
            If Current.Modulus > 4 Then Return New Escape(True, iterations)
        Next
        Return (New Escape(False, -1))
    End Function
End Module

Class Escape
    Public Property Escaped As Boolean = False
    Public Property Iterations As Integer

    Sub New(E As Boolean, I As Integer)
        Escaped = E
        Iterations = I
    End Sub
End Class

Class ComplexNumber
    Public Property Real As Double
    Public Property Complex As Double
    Sub New(R As Double, C As Double)
        Real = R
        Complex = C
    End Sub
    Function Squared() As ComplexNumber
        Dim RealTemp As Double = Real * Real - Complex * Complex
        Complex = 2 * Real * Complex
        Real = RealTemp
        Return New ComplexNumber(Real, Complex)
    End Function
    Function Modulus() As Double
        Return Real * Real + Complex * Complex
    End Function
    Function Add(Num As ComplexNumber) As ComplexNumber
        Return New ComplexNumber(Real + Num.Real, Complex + Num.Complex)
    End Function
End Class

References

https://en.wikipedia.org/wiki/Julia_set