קובץ:Square round triangular peg.stl

לקובץ המקורי(5,120 × 2,880 פיקסלים, גודל הקובץ: 26 ק"ב, סוג MIME‏: application/sla)

זהו קובץ מתוך ויקישיתוף וניתן להשתמש בו גם במיזמים אחרים. תיאורו בדף תיאור הקובץ שלו מוצג למטה.

View Square round triangular peg.stl  on viewstl.com

תקציר

תיאור
English: An object with square, round and triangular cross-sections with corresponding holes.
מקור נוצר על־ידי מעלה היצירה
יוצר Cmglee

Python source code

#!/usr/bin/env python

header = 'An object with square, round and triangular cross-sections, by CMG Lee.'
n = 30 ## number of facets in 1 quadrant
r = 10 ## circle radius
t = 2  ## plate thickness

import re, struct, math
def fmt(string): ## string.format(**vars()) using tags {expression!format} by CMG Lee
 def f(tag): i_sep = tag.rfind('!'); return (re.sub('\.0+$', '', str(eval(tag[1:-1])))
  if (i_sep < 0) else ('{:%s}' % tag[i_sep + 1:-1]).format(eval(tag[1:i_sep])))
 return (re.sub(r'(?<!{){[^{}]+}', lambda m:f(m.group()), string)
         .replace('{{', '{').replace('}}', '}'))
def append(obj, string): return obj.append(fmt(string))
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]
def roundm(x, multiple=1):
 if   (isinstance(x, tuple)): return tuple(roundm(list(x), multiple))
 elif (isinstance(x, list )): return [roundm(x_i, multiple) for x_i in x]
 else: return int(math.floor(float(x) / multiple + 0.5)) * multiple
def rotate(facetss, deg_x, deg_y, deg_z): ## around x then y then z axes
 (sin_x, cos_x) = (math.sin(math.radians(deg_x)), math.cos(math.radians(deg_x)))
 (sin_y, cos_y) = (math.sin(math.radians(deg_y)), math.cos(math.radians(deg_y)))
 (sin_z, cos_z) = (math.sin(math.radians(deg_z)), math.cos(math.radians(deg_z)))
 facet_rotatess = []
 for facets in facetss:
  facet_rotates = []
  for i_point in range(4):
   (x, y, z) = [facets[3 * i_point + i_xyz] for i_xyz in range(3)]
   if (x is None or y is None or z is None):
    facet_rotates += [x, y, z]
   else:
    (y, z) = (y * cos_x - z * sin_x,  y * sin_x + z * cos_x) ## rotate about x
    (x, z) = (x * cos_y + z * sin_y, -x * sin_y + z * cos_y) ## rotate about y
    (x, y) = (x * cos_z - y * sin_z,  x * sin_z + y * cos_z) ## rotate about z
    facet_rotates += [round(value, 9) for value in [x, y, z]]
  facet_rotatess.append(facet_rotates)
 return facet_rotatess
def translate(facetss, dx, dy, dz):
 ds = [dx, dy, dz]
 return [facets[:3] + [facets[3 * i_point + i_xyz] + ds[i_xyz]
                       for i_point in range(1,4) for i_xyz in range(3)]
         for facets in facetss]

## Add facets
facet_pegss = [
 [None,0,0,  r,0, r,  0, r,-r,  -r,0, r],
 [None,0,0, -r,0, r,  0,-r,-r,   r,0, r],
 [None,0,0,  r,0,-r,  0,-r,-r,  -r,0,-r],
 [None,0,0, -r,0,-r,  0, r,-r,   r,0,-r],
]
(x_previous,y_previous) = (r,0)
for i_facet in range(1, n + 1):
 rad   = math.pi * 0.5 * i_facet / n
 (x,y) = (math.cos(rad) * r,math.sin(rad) * r)
 facet_pegss.append( [None,0,0,  r,0, r,   x_previous, y_previous,-r,   x, y,-r])
 facet_pegss.append( [None,0,0, -r,0, r,  -x_previous,-y_previous,-r,  -x,-y,-r])
 facet_pegss.append( [None,0,0,  r,0, r,   x,-y,-r,   x_previous,-y_previous,-r])
 facet_pegss.append( [None,0,0, -r,0, r,  -x, y,-r,  -x_previous, y_previous,-r])
 if (i_facet > 1):
  facet_pegss.append([None,0,0,  r,0,-r,   x, y,-r,   x_previous, y_previous,-r])
  facet_pegss.append([None,0,0, -r,0,-r,  -x,-y,-r,  -x_previous,-y_previous,-r])
  facet_pegss.append([None,0,0,  r,0,-r,   x_previous,-y_previous,-r,   x,-y,-r])
  facet_pegss.append([None,0,0, -r,0,-r,  -x_previous, y_previous,-r,  -x, y,-r])
 (x_previous,y_previous) = (x,y)

facet_outsidess = [
 [None,0,0,      t,     t,4 * r,       0,    -r,    r,       t,     t,   -t],
 [None,0,0,      t,     t,4 * r,       0,-2 * r,3 * r,       0,    -r,    r],
 [None,0,0,      t,     t,4 * r,       t,-4 * r,4 * r,       0,-2 * r,3 * r],
 [None,0,0,      t,-4 * r,4 * r,       0,-3 * r,    r,       0,-2 * r,3 * r],
 [None,0,0,      t,-4 * r,4 * r,       t,-4 * r,   -t,       0,-3 * r,    r],
 [None,0,0,      t,-4 * r,   -t,       0,    -r,    r,       0,-3 * r,    r],
 [None,0,0,      t,-4 * r,   -t,       t,     t,   -t,       0,    -r,    r],

 [None,0,0, -4 * r,     t,   -t,      -r,     0,    r,       t,     t,   -t],
 [None,0,0, -4 * r,     t,   -t,  -3 * r,     0,    r,      -r,     0,    r],
 [None,0,0, -4 * r,     t,   -t,  -3 * r,     0,3 * r,  -3 * r,     0,    r],
 [None,0,0, -4 * r,     t,   -t,  -4 * r,     t,4 * r,  -3 * r,     0,3 * r],
 [None,0,0,      t,     t,4 * r,  -3 * r,     0,3 * r,  -4 * r,     t,4 * r],
 [None,0,0,      t,     t,4 * r,      -r,     0,3 * r,  -3 * r,     0,3 * r],
 [None,0,0,      t,     t,4 * r,      -r,     0,    r,      -r,     0,3 * r],
 [None,0,0,      t,     t,4 * r,       t,     t,   -t,      -r,     0,    r],
]
corner_bottomss = [[t,t], [-4 * r,t], [-4 * r,-4 * r], [t,-4 * r]]
for (i_corner_bottom, (x_corner_bottom,y_corner_bottom)) in enumerate(corner_bottomss):
 (x_previous,y_previous,z_previous) = corner_bottomss[(i_corner_bottom + 3) % 4] + [-t]
 for i_facet in range(n + 1):
  rad     = math.pi * 0.5 * (i_corner_bottom + i_facet / n)
  (x,y,z) = ((math.cos(rad) - 2) * r,(math.sin(rad) - 2) * r,0)
  facet_outsidess.append([None,0,0, x_corner_bottom,y_corner_bottom,-t,
                                    x_previous,y_previous,z_previous, x,y,z])
  (x_previous,y_previous,z_previous) = (x,y,z)

facet_rimss = [
 [None,0,0,   t,-4 * r,4 * r,    t,     t,4 * r,    0,     0,4 * r],
 [None,0,0,   t,-4 * r,4 * r,    0,     0,4 * r,    0,-4 * r,4 * r],
 [None,0,0,   t,-4 * r,4 * r,    0,-4 * r,4 * r,    0,-4 * r,    0],
 [None,0,0,   t,-4 * r,4 * r,    0,-4 * r,    0,    t,-4 * r,   -t],
]
facet_rimss += rotate(facet_rimss    ,   0,90,-90)
facet_rimss += rotate(facet_rimss[:4], -90, 0, 90)

facet_insidess = [[facets[i_value] if (facets[i_value] is None or abs(facets[i_value]) != t) else 0
                   for i_value in [0,1,2, 3,4,5, 9,10,11, 6,7,8]] for facets in facet_outsidess]

facetss = facet_pegss + translate(facet_outsidess + facet_rimss + facet_insidess,
                                  2 * r, 2 * r, -2 * r)
# facetss = [facets[:6] + facets[9:12] + facets[6:9] for facets in facetss]

## Calculate 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([['%s%d' % (xyz, n) for n in range(3) for xyz in list('XYZ')] +
               ['N%s'  % (xyz) for xyz in list('xyz')] + ['s0f']] + 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])
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)
 # f_out.write('%s\n## Python script to generate STL\n%s\n' % (''.join(outs), open(__file__).read()))

רישיון

Wikimedia Foundation
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.
אני, בעל זכויות היוצרים על היצירה הזאת, מפרסם אותה בזאת תחת הרישיונות הבאים:
w:he:Creative Commons
ייחוס שיתוף זהה
הקובץ הזה מתפרסם לפי תנאי רישיון קריאייטיב קומונז ייחוס-שיתוף זהה 4.0 בין־לאומי.
הנכם רשאים:
  • לשתף – להעתיק, להפיץ ולהעביר את העבודה
  • לערבב בין עבודות – להתאים את העבודה
תחת התנאים הבאים:
  • ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
  • שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.
GNU head מוענקת בכך הרשות להעתיק, להפיץ או לשנות את המסמך הזה, לפי תנאי הרישיון לשימוש חופשי במסמכים של גנו, גרסה 1.2 או כל גרסה מאוחרת יותר שתפורסם על־ידי המוסד לתוכנה חופשית; ללא פרקים קבועים, ללא טקסט עטיפה קדמית וללא טקסט עטיפה אחורית. עותק של הרישיון כלול בפרק שכותרתו הרישיון לשימוש חופשי במסמכים של גנו.
הנכם מוזמנים לבחור את הרישיון הרצוי בעיניכם.

כיתובים

נא להוסיף משפט שמסביר מה הקובץ מייצג

פריטים שמוצגים בקובץ הזה

מוצג

היסטוריית הקובץ

ניתן ללחוץ על תאריך/שעה כדי לראות את הקובץ כפי שנראה באותו זמן.

תאריך/שעהתמונה ממוזערתממדיםמשתמשהערה
נוכחית15:57, 20 במרץ 2018תמונה ממוזערת לגרסה מ־15:57, 20 במרץ 2018‪2,880 × 5,120‬ (26 ק"ב)CmgleeMove concavity to outside faces.
00:14, 20 במרץ 2018תמונה ממוזערת לגרסה מ־00:14, 20 במרץ 2018‪2,880 × 5,120‬ (26 ק"ב)CmgleeFlip vertex order and increase number of facets.
00:08, 20 במרץ 2018תמונה ממוזערת לגרסה מ־00:08, 20 במרץ 2018‪2,880 × 5,120‬ (17 ק"ב)Cmglee{{Information |description ={{en|1=An object with square, round and triangular cross-sections.}} |source ={{own}} |author =User:Cmglee |date = }} Category:STL files Category:Solids

הדף הבא משתמש בקובץ הזה:

שימוש גלובלי בקובץ

אתרי הוויקי השונים הבאים משתמשים בקובץ זה: