Golden Spiral
The Golden Spiral was a challenging visualisation to produce. In order to create the spiral, it was necessary to make many translations to the curve function of the spiral itself. In this case, the translations were applied to the arc function in VB.Net. Challenges presented themselves in discerning the specific translations that were needed for each segment of the curve.
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
64
Imports System.Drawing
Module GoldenSpiral
Sub Main()
Dim Phi As Double = (1 + Math.Sqrt(5)) / 2
Using bmp As New Drawing.Bitmap(3860, 2180), Graphics As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)
' Original square
Dim TopLeft As New Point(0, 0)
Dim TopRight As New Point(3840, 0)
Dim BottomLeft As New Point(0, 2160)
Dim BottomRight As New Point(3840, 2160)
Dim Min As Boolean = True
Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
For i = 0 To 6
Dim CurrentLength As Double = TopRight.X - TopLeft.X
Dim CurrentHeight As Double = BottomRight.Y - TopRight.Y
'Horizontal lines
Dim AHorizontal As Double = CurrentLength / (Phi + 1)
Dim BHorizontal As Double = CurrentLength - AHorizontal
' Vertical Line
Dim AVer As Double = CurrentHeight / (Phi + 1)
Dim BVer As Double = CurrentHeight - AVer
If Min = True Then
' First part of curve
Graphics.DrawArc(Pens.White, New Rectangle(New Point(TopLeft.X + 10, TopLeft.Y + 10), New Size(BHorizontal * 2, CurrentHeight * 2)), 180, 90)
' Update square
BottomLeft = New Point(Math.Floor(TopLeft.X + BHorizontal), BottomLeft.Y)
TopLeft = New Point(Math.Floor(TopLeft.X + BHorizontal), TopLeft.Y)
Graphics.DrawArc(Pens.White, New Rectangle(New Point(TopLeft.X - (CurrentLength - BHorizontal) + 10, TopLeft.Y + 10), New Size((CurrentLength - BHorizontal) * 2, BVer * 2)), -90, 90)
TopRight = New Point(TopRight.X, Math.Floor(TopLeft.Y + BVer))
TopLeft = New Point(TopLeft.X, Math.Floor(TopLeft.Y + BVer))
Min = False
Else
Graphics.DrawArc(Pens.White, New Rectangle(New Point(TopLeft.X - (BHorizontal - AHorizontal) + 10, TopLeft.Y - CurrentHeight + 10), New Size(BHorizontal * 2, CurrentHeight * 2)), 90, -90)
BottomRight = New Point(Math.Floor(TopLeft.X + AHorizontal), BottomLeft.Y)
TopRight = New Point(Math.Floor(TopLeft.X + AHorizontal), TopLeft.Y)
Graphics.DrawArc(Pens.White, New Rectangle(New Point(TopLeft.X + 10, TopLeft.Y - (BVer - AVer) + 10), New Size(AHorizontal * 2, (CurrentHeight - AVer) * 2)), 90, 90)
BottomLeft = New Point(Math.Floor(BottomLeft.X), Math.Floor(TopLeft.Y + AVer))
BottomRight = New Point(Math.Floor(BottomRight.X), Math.Floor(TopLeft.Y + AVer))
Min = True
End If
Next
'Save Curve
bmp.Save("GoldenSpiral.bmp", Imaging.ImageFormat.Bmp)
End Using
End Sub
End Module