-#!/usr/bin/python
+#!/usr/bin/python3
from __future__ import print_function
signal.signal(signal.SIGINT, signal.SIG_DFL)
from moebius import *
+from scad import *
-nomsize = 20
-thick = 1.0
+nomsize = 30;
+thick = 2.000;
sliceat = 1.675;
m = Moebius(nv, nw)
-
-class ScadObject:
- def __init__(so):
- so._points = []
- so._point_indices = {}
- so._triangles = []
-
- def writeout(so, objname, scalefactor=1):
- print('module %s(){ scale(%s) polyhedron(points=[' %
- (objname, scalefactor))
- for p in so._points: print(p, ',')
- print('],faces=[')
- for t in so._triangles: print(repr(t), ',')
- print('],convexity=10); }')
- so._points = None
-
- def _point(so, p):
- l = list(p)
- s = repr(l)
- try:
- ix = so._point_indices[s]
- except KeyError:
- ix = len(so._points)
- so._points.append(s)
- so._point_indices[s] = ix
- return ix
-
- def triangle(so, a,b,c):
- ''' a b c are clockwise from inside '''
- so._triangles.append([ so._point(p) for p in (a,b,c) ])
-
- def quad(so, cnrs):
- ''' cnrs[0] [1] [3] [2] are clockwise from inside '''
- so.triangle(cnrs[0], cnrs[1], cnrs[3])
- so.triangle(cnrs[0], cnrs[3], cnrs[2])
-
- def rquad(so, cnrs):
- ''' cnrs[0] [1] [3] [2] are anticlockwise from inside '''
- so.triangle(cnrs[0], cnrs[3], cnrs[1])
- so.triangle(cnrs[0], cnrs[2], cnrs[3])
-
relthick = thick/(nomsize*2)
def make_moebius(objname):
if (bests[best_key] is None or
goodness(prospective) > goodness(bests[best_key])):
bests[best_key] = prospective
- def print_bests(name, info_index):
+ def print_best_list(name, l):
print('moebius_pin_%s=[' % name)
- for b in bests: print(repr(list(b[info_index])),',')
+ for i in l: print(repr(list(i)),',')
print('];')
+ def print_bests(name, info_index):
+ print_best_list(name, [b[info_index] for b in bests])
print_bests('locns', 0)
print_bests('normals', 1)
+ upwardses = []
+ alongs = []
+ matrices = []
+ for b in bests:
+ along = unit_v(np.cross(b[1], unit_z))
+ upwards = np.cross(b[1], along)
+ matrix = [ along,
+ -upwards,
+ -b[1] ]
+ #print('initial', matrix, file=sys.stderr)
+ matrix = np.concatenate((matrix, [[0,0,0]]))
+ #print('concatd', matrix, file=sys.stderr)
+ matrix = np.array(matrix).T
+ #print('transposed', matrix, file=sys.stderr)
+ matrix = np.concatenate((matrix, [[0,0,0,1]]))
+ #print('concat2', matrix, file=sys.stderr)
+ matrix = [ list(row) for row in matrix ]
+ #print('listed', matrix, file=sys.stderr)
+ alongs .append(along)
+ upwardses.append(upwards)
+ matrices. append(matrix)
+ print_best_list('upwardses',upwardses)
+ print_best_list('alongs', alongs)
+ print_best_list('matrix', matrices)
make_moebius('MoebiusCore')
make_pinlocations()
print('moebiuscore_nomsize=%s;' % repr(nomsize))
+print('moebiuscore_sliceat=%s;' % repr(sliceat))