From 8861686be59d123e7506170ce12fc5fbd2d85cee Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 25 Nov 2017 22:47:34 +0000 Subject: [PATCH] helixish: wip Signed-off-by: Ian Jackson --- helixish.py | 34 ++++++++++++++++++++++++++++++++++ moedebug.py | 7 +++++++ 2 files changed, 41 insertions(+) create mode 100644 moedebug.py diff --git a/helixish.py b/helixish.py index 4eaa140..3479910 100644 --- a/helixish.py +++ b/helixish.py @@ -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 index 0000000..a42f3a6 --- /dev/null +++ b/moedebug.py @@ -0,0 +1,7 @@ + +dbg_enable = False + +def dbg(*args): + if dbg_enable: + print(file=sys.stderr, 'D ', *args) + -- 2.30.2