chiark / gitweb /
work on norm matrix
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Nov 2017 22:28:52 +0000 (22:28 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Nov 2017 22:28:52 +0000 (22:28 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
genscad
moebius-demo.scad
moebius.py

diff --git a/genscad b/genscad
index 3440d188f923a28ae10829e8ddbfe799e7336f0f..9063c368343449d7b3e79fcbef5f3047a97a1793 100755 (executable)
--- a/genscad
+++ b/genscad
@@ -109,12 +109,38 @@ def make_pinlocations():
         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 = [ b[1],
+               upwards,
+               along ]
+    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()
index 97368998e1e9a1a1f573bd092df259ffefbc4a76..8f827bd58a3a4719716c0ec94692a3ef7f1ff667 100644 (file)
@@ -98,11 +98,8 @@ module Pin(){
 module PinDemo(){
   for (i=[0,1]) {
     translate( moebius_pin_locns[i] * moebiuscore_nomsize ) {
-      hull(){
-       sphere(2 + i);
-       translate( moebius_pin_normals[i] * moebiuscore_nomsize*0.5 )
-         sphere(2 + i);
-      }
+      multmatrix(moebius_pin_matrix[i])
+       cube(center=true, [1,4,9]);
     }
   }
 }
index d9e452d4d70105da8b537106ddc984bd2830fd45..3cea68d4f6c2b2145dc89496077ac8a0e0a96f37 100644 (file)
@@ -15,6 +15,9 @@ unit_x = np.array((1,0,0))
 unit_y = np.array((0,1,0))
 unit_z = np.array((0,0,1))
 
+def unit_v(v):
+  return v / np.linalg.norm(v)
+
 class DoubleCubicBezier():
   def __init__(db, cp):
     single = BezierSegment(cp)