Created
December 21, 2014 22:19
-
-
Save zeffii/977d3ddfa767464518c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
# connect a 11*11 matrix in Planar to the ViewerDraw | |
def int_to_binary(number_in): | |
tstr = str(bin(number_in)) | |
tstr2 = tstr[2:] | |
f = tstr2.zfill(12) | |
return tuple(int(i) for i in f) | |
def make_geometry(r, verts, edges): | |
# binary reprs of nice divisions. | |
fk = [ | |
11, 14, 23, 29, 46, 51, 53, | |
55, 57, 59, 63, 70, 81, 93, | |
94, 97, 105, 106, 107, 110, | |
114, 119, 142, 150, 154, 159, | |
162, 171, 173, 177, 182, 183, | |
191, 199, 205, 206, 207, 209, | |
218, 237, 250, 273, 285, 286, | |
291, 306, 307, 314, 318, 325, | |
346, 355, 382, 406, 411, 425, | |
429, 442, 457, 469, 477, 487, | |
491, 494, 509, 511, 547, 551, | |
586, 615, 618, 629, 630, 667, | |
678, 681, 682, 685, 694, 697, | |
698, 703, 715, 733, 741, 745, | |
746, 749, 751, 757, 761, 821, | |
826, 847, 862, 878, 890, 925, | |
957, 986, 989, 997, 1001, 1002, | |
1014, 1018, 1022, 1390, 1403, 1454, | |
1530, 1642, 1647, 1703, 1727, 1770, | |
1967, 2031, 2047, 2730, 2799] | |
v= [] | |
v.append((0,0,0)) | |
for i in range(6): | |
theta = (1/6 * math.pi * 2) * i | |
v.append((math.sin(theta)*r, math.cos(theta)*r, 0)) | |
for i in fk: | |
verts.extend([v]) | |
e = [ [0,1], [1,2], [0,2], [2,3], | |
[0,3], [3,4], [0,4], [4,5], | |
[0,5], [5,6], [0,6], [6,1]] | |
for i in fk: | |
tuup = int_to_binary(i) | |
edges.extend([[edge for t, edge in zip(tuup, e) if t==1]]) | |
def sv_main(r=0.5): | |
verts = [] | |
edges = [] | |
in_sockets = [ | |
['s', 'r', r] | |
] | |
out_sockets = [ | |
['v', 'verts', verts], | |
['s', 'edges', edges] | |
] | |
make_geometry(r, verts, edges) | |
return in_sockets, out_sockets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment