-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDodecahedron.rvb
90 lines (78 loc) · 3.7 KB
/
Dodecahedron.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Dodecahedron.rvb -- March 2012
' 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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Create a regular Dodecahedron composed of 12 regular pentagons.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Dodecahedron()
' Declare local variables
Dim center, phi, a, b
Dim v(19), p(11), s(11)
' Prompt for center point
center = Rhino.GetPoint("Center of dodecahedron")
If IsNull(center) Then Exit Sub
' This will make the script run faster
Call Rhino.EnableRedraw(False)
' A few calculations...
phi = (1.0 + Sqr(5.0)) * 0.5
a = 1 / phi
b = 1 / (phi * phi)
' Define the dodecahedron's 20 vertices
v(0) = Rhino.PointAdd(center, Array( 0, 1, b))
v(1) = Rhino.PointAdd(center, Array( 0, 1, -b))
v(2) = Rhino.PointAdd(center, Array( 0, -1, b))
v(3) = Rhino.PointAdd(center, Array( 0, -1, -b))
v(4) = Rhino.PointAdd(center, Array( 1, b, 0))
v(5) = Rhino.PointAdd(center, Array(-1, b, 0))
v(6) = Rhino.PointAdd(center, Array( 1, -b, 0))
v(7) = Rhino.PointAdd(center, Array(-1, -b, 0))
v(8) = Rhino.PointAdd(center, Array( a, a, a))
v(9) = Rhino.PointAdd(center, Array(-a, a, a))
v(10) = Rhino.PointAdd(center, Array( a, a, -a))
v(11) = Rhino.PointAdd(center, Array(-a, a, -a))
v(12) = Rhino.PointAdd(center, Array( a, -a, a))
v(13) = Rhino.PointAdd(center, Array(-a, -a, a))
v(14) = Rhino.PointAdd(center, Array( a, -a, -a))
v(15) = Rhino.PointAdd(center, Array(-a, -a, -a))
v(16) = Rhino.PointAdd(center, Array( b, 0, 1))
v(17) = Rhino.PointAdd(center, Array(-b, 0, 1))
v(18) = Rhino.PointAdd(center, Array( b, 0, -1))
v(19) = Rhino.PointAdd(center, Array(-b, 0, -1))
' Create the dodecahedron's 12 faces
p(0) = Rhino.AddPolyline(Array(v(16), v(17), v( 9), v( 0), v( 8), v(16)))
p(1) = Rhino.AddPolyline(Array(v(17), v(16), v(12), v( 2), v(13), v(17)))
p(2) = Rhino.AddPolyline(Array(v(18), v(19), v(15), v( 3), v(14), v(18)))
p(3) = Rhino.AddPolyline(Array(v(19), v(18), v(10), v( 1), v(11), v(19)))
p(4) = Rhino.AddPolyline(Array(v( 1), v( 0), v( 8), v( 4), v(10), v( 1)))
p(5) = Rhino.AddPolyline(Array(v( 0), v( 1), v(11), v( 5), v( 9), v( 0)))
p(6) = Rhino.AddPolyline(Array(v( 3), v( 2), v(13), v( 7), v(15), v( 3)))
p(7) = Rhino.AddPolyline(Array(v( 2), v( 3), v(14), v( 6), v(12), v( 2)))
p(8) = Rhino.AddPolyline(Array(v( 4), v( 6), v(12), v(16), v( 8), v( 4)))
p(9) = Rhino.AddPolyline(Array(v( 6), v( 4), v(10), v(18), v(14), v( 6)))
p(10) = Rhino.AddPolyline(Array(v( 5), v( 7), v(15), v(19), v(11), v( 5)))
p(11) = Rhino.AddPolyline(Array(v( 7), v( 5), v( 9), v(17), v(13), v( 7)))
s(0) = Rhino.AddPlanarSrf(Array(p(0)))(0)
s(1) = Rhino.AddPlanarSrf(Array(p(1)))(0)
s(2) = Rhino.AddPlanarSrf(Array(p(2)))(0)
s(3) = Rhino.AddPlanarSrf(Array(p(3)))(0)
s(4) = Rhino.AddPlanarSrf(Array(p(4)))(0)
s(5) = Rhino.AddPlanarSrf(Array(p(5)))(0)
s(6) = Rhino.AddPlanarSrf(Array(p(6)))(0)
s(7) = Rhino.AddPlanarSrf(Array(p(7)))(0)
s(8) = Rhino.AddPlanarSrf(Array(p(8)))(0)
s(9) = Rhino.AddPlanarSrf(Array(p(9)))(0)
s(10) = Rhino.AddPlanarSrf(Array(p(10)))(0)
s(11) = Rhino.AddPlanarSrf(Array(p(11)))(0)
' Join all of the faces
Rhino.UnselectAllObjects()
Call Rhino.SelectObjects(s)
Call Rhino.Command("_Join", False)
Call Rhino.DeleteObjects(p)
Rhino.UnselectAllObjects()
' Don't forget to do this
Call Rhino.EnableRedraw(True)
End Sub