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]
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
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]
+