chiark / gitweb /
helixish: remember to transform back from findcurve basis (!)
[moebius3.git] / genscad
diff --git a/genscad b/genscad
index 9063c368343449d7b3e79fcbef5f3047a97a1793..62fb2ce4758699100f514356406d9fb64fbeaf1c 100755 (executable)
--- a/genscad
+++ b/genscad
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from __future__ import print_function
 
@@ -6,9 +6,10 @@ import signal
 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;
 
@@ -17,47 +18,6 @@ nw = 80
 
 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):
@@ -123,18 +83,18 @@ def make_pinlocations():
   for b in bests:
     along = unit_v(np.cross(b[1], unit_z))
     upwards = np.cross(b[1], along)
-    matrix = [ b[1],
-               upwards,
-               along ]
-    print('initial', matrix, file=sys.stderr)
+    matrix = [ along,
+               -upwards,
+               -b[1] ]
+    #print('initial', matrix, file=sys.stderr)
     matrix = np.concatenate((matrix, [[0,0,0]]))
-    print('concatd', matrix, file=sys.stderr)
+    #print('concatd', matrix, file=sys.stderr)
     matrix = np.array(matrix).T
-    print('transposed', matrix, file=sys.stderr)
+    #print('transposed', matrix, file=sys.stderr)
     matrix = np.concatenate((matrix, [[0,0,0,1]]))
-    print('concat2', matrix, file=sys.stderr)
+    #print('concat2', matrix, file=sys.stderr)
     matrix = [ list(row) for row in matrix ]
-    print('listed', matrix, file=sys.stderr)
+    #print('listed', matrix, file=sys.stderr)
     alongs   .append(along)
     upwardses.append(upwards)
     matrices. append(matrix)