File:De bruijn torus 3x3.stl
Page contents not supported in other languages.
Tools
Actions
General
In other projects
Appearance
Size of this PNG preview of this STL file: 800 × 600 pixels. Other resolutions: 320 × 240 pixels | 640 × 480 pixels | 1,024 × 768 pixels | 1,280 × 960 pixels | 2,560 × 1,920 pixels | 5,120 × 3,840 pixels.
Original file (5,120 × 2,880 pixels, file size: 50 KB, MIME type: application/sla)
This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
View De bruijn torus 3x3.stl on viewstl.com
Summary
DescriptionDe bruijn torus 3x3.stl | De Bruijn torus (16, 32; 3, 3) from http://github.com/man4/debruijn-torus rendered as a torus with ones as panels and zeros as holes by_CMG_Lee. |
Source | Own work |
Author | Cmglee |
#!/usr/bin/env python
header = 'De Bruijn torus (16, 32; 3, 3) with 1 as panels and 0 as holes by CMG Lee'
(r_row,r_col) = (300,600)
rot_col = 270
f = 0.01
datass = [[int(char) for char in line] for line in '''
00000010111001011100101110010111
00010011111101001101101010000110
00000010111001011100101110010111
11101100000010110010010101111001
00000010111001011100101110010111
00010011111101001101101010000110
00110001110101101111100010100100
10001010011011010100001100011111
11111101000110100011010001101000
11101100000010110010010101111001
10101000010011110110000100111101
01000110101000011000111111010011
11111101000110100011010001101000
11101100000010110010010101111001
01100100100000111010110111110001
11011111001110000001011001001010
'''.strip().split()]
(n_row,n_col) = (len(datass),len(datass[0]))
import math, struct
def tabbify(cellss, separator='|'):
cellpadss = [list(rows) + [''] * (len(max(cellss, key=len)) - len(rows)) for rows in cellss]
fmts = ['%%%ds' % (max([len(str(cell)) for cell in cols])) for cols in zip(*cellpadss)]
return '\n'.join([separator.join(fmts) % tuple(rows) for rows in cellpadss])
def hex_rgb(colour): ## convert [#]RGB to #RRGGBB and [#]RRGGBB to #RRGGBB
return '#%s' % (colour if len(colour) > 4 else ''.join([c * 2 for c in colour])).lstrip('#')
def viscam_colour(colour):
colour_hex = hex_rgb(colour)
colour_top5bits = [int(colour_hex[i:i+2], 16) >> 3 for i in range(1,7,2)]
return (1 << 15) + (colour_top5bits[0] << 10) + (colour_top5bits[1] << 5) + colour_top5bits[2]
## Find vertices
xyzsss = []
for i_row in range(n_row):
xyzss = []
for i_col in range(n_col):
theta_row = 2 * math.pi * i_row / n_row
theta_col = 2 * math.pi * i_col / n_col
r_row_sin = r_row * math.sin(theta_row)
x = (r_col + r_row_sin) * math.cos(theta_col + math.radians(rot_col))
y = (r_col + r_row_sin) * math.sin(theta_col + math.radians(rot_col))
z = r_row * math.cos(theta_row)
xyzss.append([x,y,z])
xyzsss.append(xyzss)
## Find facets
facetss = []
for i_row in range(n_row):
for i_col in range(n_col):
xyz_currents = xyzsss[(i_row ) % n_row][(i_col ) % n_col]
xyz_next_rows = xyzsss[(i_row + 1) % n_row][(i_col ) % n_col]
xyz_next_cols = xyzsss[(i_row ) % n_row][(i_col + 1) % n_col]
xyz_next_row_cols = xyzsss[(i_row + 1) % n_row][(i_col + 1) % n_col]
xyz_inters = [f * xyz_currents[i] + (1 - f) * xyz_next_row_cols[i] for i in range(3)]
if datass[i_row][i_col] == 0: xyz_currents = xyz_inters
# else: xyz_next_row_cols = xyz_inters
facetss.append([None,None,None] + xyz_currents + xyz_next_cols + xyz_next_row_cols)
facetss.append([None,None,None] + xyz_currents + xyz_next_row_cols + xyz_next_rows)
## Calculate normals for facets with unknown normals
for facets in facetss:
if (facets[0] is None or facets[1] is None or facets[2] is None):
us = [facets[i_xyz + 9] - facets[i_xyz + 6] for i_xyz in range(3)]
vs = [facets[i_xyz + 6] - facets[i_xyz + 3] for i_xyz in range(3)]
normals = [us[1]*vs[2] - us[2]*vs[1], us[2]*vs[0] - us[0]*vs[2], us[0]*vs[1] - us[1]*vs[0]]
normal_length = sum([component * component for component in normals]) ** 0.5
facets[:3] = [-round(component / normal_length, 10) for component in normals]
# print(tabbify([['N%s' % (xyz ) for xyz in list('xyz')] +
# ['%s%d' % (xyz, n) for n in range(3) for xyz in list('XYZ')] + ['RGB']] + facetss))
## Compile STL
outss = ([[('STL\n\n%-73s\n\n' % (header[:73])).encode('utf-8'), struct.pack('<L',len(facetss))]] +
[[struct.pack('<f',float(value)) for value in facets[:12]] +
[struct.pack('<H',0 if (len(facets) <= 12) else
viscam_colour(facets[12]))] for facets in facetss])
out = b''.join([bytes(out) for outs in outss for out in outs])
# out += ('\n\n## Python script to generate STL\n\n%s\n' % (open(__file__).read())).encode('utf-8')
print("# bytes:%d\t# facets:%d\ttitle:\"%-73s\"" % (len(out), len(facetss), header[:73]))
with open(__file__[:__file__.rfind('.')] + '.stl', 'wb') as f_out: f_out.write(out)
Licensing
The uploader of this file has agreed to the Wikimedia Foundation 3D patent license: This file and any 3D objects depicted in the file are both my own work. I hereby grant to each user, maker, or distributor of the object depicted in the file a worldwide, royalty-free, fully-paid-up, nonexclusive, irrevocable and perpetual license at no additional cost under any patent or patent application I own now or in the future, to make, have made, use, offer to sell, sell, import, and distribute this file and any 3D objects depicted in the file that would otherwise infringe any claims of any patents I hold now or in the future. Please note that in the event of any differences in meaning or interpretation between the original English version of this license and a translation, the original English version takes precedence. |
I, the copyright holder of this work, hereby publish it under the following licenses:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
You may select the license of your choice.
Items portrayed in this file
depicts
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 23:41, 25 May 2021 | 5,120 × 2,880 (50 KB) | Cmglee | Close holes between panels. | |
20:15, 25 May 2021 | 5,120 × 2,880 (50 KB) | Cmglee | {{Information |Description=De Bruijn torus (16, 32; 3, 3) from http://github.com/man4/debruijn-torus rendered as a torus with ones as panels and zeros as holes by_CMG_Lee. |Source={{own}} |Date= |Author= Cmglee |Permission= |other_versions= }} Category:STL files by cmglee Category:STL mathematics Category:De Bruijn sequence |
File usage
The following 3 pages use this file:
Retrieved from "https://en.wikipedia.org/wiki/File:De_bruijn_torus_3x3.stl"