chiark / gitweb /
helixish: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Nov 2017 22:47:34 +0000 (22:47 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Nov 2017 22:47:34 +0000 (22:47 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
helixish.py
moedebug.py [new file with mode: 0644]

index 4eaa140c885c8b2d8da19d90e2e24f3a2bd507b1..3479910e1451a3c44dcbf15b6acd154c7873ec1d 100644 (file)
@@ -5,11 +5,14 @@ import numpy as np
 from numpy import cos, sin
 
 import sys
+from moebdebug import dbg
 
 def augment(v): return np.append(v, 1)
 def augment0(v): return np.append(v, 0)
 def unaugment(v): return v[0:3]
 
+findcurve_subproc = None
+
 class HelixishCurve():
   def __init__(hc, cp):
     p = cp[0]
@@ -17,6 +20,8 @@ class HelixishCurve():
     dp = unit_v(cp[1]-cp[0])
     dq = unit_v(cp[3]-cp[2])
 
+    dbg('HelixishCurve __init__', cp)
+
     # the initial attempt
     #   - solve in the plane containing dP and dQ
     #   - total distance normal to that plane gives mu
@@ -114,4 +119,33 @@ class HelixishCurve():
     findcurve_start = (sqrt(start_s), sqrt(start_t), start_la,
                        start_mu, start_gamma, start_kappa)
     
+    findcurve_epsilon = dist_pq_plane * 0.01
+
+    if findcurve_subproc is None:
+      findcurve_subproc = subprocess.Popen(
+        ['./findcurve'],
+        bufsize=1,
+        stdin=subprocess.PIPE,
+        stdout=subprocess.PIPE,
+        stderr=None,
+        close_fds=False,
+        restore_signals=True,
+        universal_newlines=True,
+      )
+
+    findcurve_input = np.hstack((findcurve_target,
+                                 findcurve_start,
+                                 [findcurve_epsilon])))
+    dbg('RUNNING FINDCURVE', *findcurve_input)
+    print(findcurve_subproc.stdin, *findcurve_input)
+    findcurve_subproc.stdin.flush()
+
+    while True:
+      l = findcurve_subproc.stdout.readline()
+      l = l.rstrip()
+      dbg('GOT ', l)
+      l = eval(l)
+      if l is None: break
+      findcurve_result = l[0:5]
+
     
diff --git a/moedebug.py b/moedebug.py
new file mode 100644 (file)
index 0000000..a42f3a6
--- /dev/null
@@ -0,0 +1,7 @@
+
+dbg_enable = False
+
+def dbg(*args):
+  if dbg_enable:
+    print(file=sys.stderr, 'D ', *args)
+