# First Daisy

Spirals are drawn as either individual lines or a connected polyline. A polyline in autocad vba requires an array of points in the form (x1,y1,x2,y2,x3…). This is constructed with a loop that runs once for each point and adds an x and y value to an array each time through the loop. The polyline is drawn outside the loop with a single statement.

The spiral consisting of individual lines is drawn with a loop that runs once for each line. It stores values for two points x1,y1 and x2,y2 each time through the loop. It draws one line segment inside the loop each time through.

The fermat spiral is sometimes used to draw plant simulations using a bit of geometry at each node rather than a straight line. Instead of calling the line subroutine, any other geometry can be called inside the loop. These are sometimes called daisies or sunflowers.

```
Sub fermat_spiral_daisy1()
'R = B A^1/2
Call init_polar
Dim B As Double, C As Double
Dim i As Integer
Dim numlines As Integer
Dim R1 As Double, R2 As Double
Dim A1 As Integer, A2 As Integer
Dim X1 As Double, X2 As Double
Dim Y1 As Double, Y2 As Double

B = frm_polar.txt_b8.Value
C = 0.5

numlines = (Amax - Amin) / A_inc 'num of lines

For i = 1 To numlines
A1 = Amin + ((i - 1) * A_inc)
A2 = Amin + (i * A_inc)

'this is the function
R1 = B * (A1_rad ^ C)
R2 = B * (A2_rad ^ C)

'this would be the regular spiral
'Call line(X1, Y1, X2, Y2)

Call polygon3(R2, A2)

Next i

Update
End Sub

Sub polygon3(R As Double, A As Integer)

Dim X As Double, Y As Double
Dim pt() As Double
Dim t As Integer, numpts As Integer

numpts = 7
ReDim pt(1 To numpts * 2) 'to store both x and y for one pt

Dim AA As Double
Dim RR As Integer
RR = 3

For t = 1 To 7
AA = 2 * pi * t / 6 + deg2rad(A)

X = RR * Cos(AA) + R * Cos(A)
Y = RR * Sin(AA) + R * Sin(A)
pt(t * 2 - 1) = X: pt(t * 2) = Y
Next t