-
Notifications
You must be signed in to change notification settings - Fork 335
/
Copy pathCompleteGraph.rvb
58 lines (44 loc) · 1.56 KB
/
CompleteGraph.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
48
49
50
51
52
53
54
55
56
57
58
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' CompleteGraph.rvb -- April 2013
' If this code works, it was written by Dale Fugier.
' If not, I don't know who wrote it.
' Works with Rhino 4 and 5.
'
' http://en.wikipedia.org/wiki/Complete_graph
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Draw lines between a number of points spaced
' evenly around the circumference of a circle.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub CompleteGraph
Dim center, radius, count
Dim points, i, j
center = Array(0, 0, 0) ' Center of circle
radius = 5.0 ' Radius of circle
count = 19 ' Points on circle
'Call Rhino.EnableRedraw(False)
points = PointsOnCircle(center, radius, count)
For i = 0 To count - 1
For j = i + 1 To count - 1
Call Rhino.AddLine(points(i), points(j))
Next
Next
'Call Rhino.EnableRedraw(True)
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Calculate points on the circle
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function PointsOnCircle(center, radius, count)
Dim alpha, theta, points(), i
ReDim points(count-1)
alpha = Rhino.PI * 2 / count
For i = 0 To count - 1
theta = alpha * i
points(i) = Array( _
center(0) + Cos(theta) * radius, _
center(1) + Sin(theta) * radius, _
center(2))
Next
PointsOnCircle = points
End Function