+ lincomb = (-sliceat - p[2]) / (q[2] - p[2])
+ here = p * (1-lincomb) + q * lincomb;
+ best_key = here[1] >= 0
+ prospective = (here,normal)
+ if (bests[best_key] is None or
+ goodness(prospective) > goodness(bests[best_key])):
+ bests[best_key] = prospective
+ def print_best_list(name, l):
+ print('moebius_pin_%s=[' % name)
+ 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)