forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArchimedeanSpiral.rvb
47 lines (35 loc) · 1.51 KB
/
ArchimedeanSpiral.rvb
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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ArchimedeanSpiral.rvb -- June 2008
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4.0.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Creates an archimedean spiral.
' Change 'a_const' to turn the spiral.
' Change 'b_const' to control the distance between turnings.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ArchimedeanSpiral()
Dim a_const, b_const, step_angle, num_points
Dim curr_angle, base_point, radius, points(), i
Rhino.Print "Archimedean Spiral: 'Radius = A + B * Theta'"
a_const = Rhino.GetReal("Value of 'A' constant", 1.0, 0.01)
If IsNull(a_const) Then Exit Sub
b_const = Rhino.GetReal("Value of 'B' constant", 1.0, 0.01)
If IsNull(a_const) Then Exit Sub
num_points = Rhino.GetInteger("Number of points to calculate", 10, 2)
If IsNull(num_points) Then Exit Sub
step_angle = Rhino.GetReal("Angle between points", 30.0, 1.0, 45.0)
If IsNull(step_angle) Then Exit Sub
curr_angle = 0.0
base_point = Array(0.0, 0.0, 0.0)
ReDim points(num_points - 1)
For i = 0 To UBound(points)
radius = a_const + (b_const * curr_angle)
points(i) = Rhino.Polar(base_point, radius, curr_angle)
curr_angle = curr_angle + step_angle
Next
Rhino.AddInterpCurve points
'Rhino.AddPoints points
End Sub