2 from __future__ import print_function
5 from numpy import cos, sin
10 from moedebug import *
14 from math import atan2, atan, sqrt
18 findcurve_subprocs = { }
20 class OptimisedCurve():
21 def __init__(oc, cp, nt):
22 db = DiscreteBezier(cp, nt, constructor=BezierSegment)
23 fc_input = map(db.point_at_it, range(0, nt+1))
24 for end in (False,True):
30 ef_dirn =unit_v(cp[cp1i] - cp[cp0i])
31 ef_len = np.linalg.norm(fc_input[fi] - fc_input[ei])
32 f = e + ef_dirn * ef_len
36 findcurve_epsilon = dist_pq_plane * 0.01
39 subproc = findcurve_subprocs[nt]
41 dbg('STARTING FINDCURVE %d' % nt)
42 subproc = subprocess.Popen(
43 ['./findcurve', '%d' % nt],
45 stdin=subprocess.PIPE,
46 stdout=subprocess.PIPE,
49 # restore_signals=True, // want python2 compat, nnng
50 universal_newlines=True,
52 findcurve_subprocs[nt] = subproc
54 dbg(('RUNNING FINDCURVE')
56 findcurve_input = np.hstack(*findcurve_input)
57 s = ' '.join(map(str, findcurve_input))
61 print(s, file=findcurve_subproc.stdin)
62 findcurve_subproc.stdin.flush()
67 l = findcurve_subproc.stdout.readline()
70 if not l: vdbg().crashing('findcurve EOF')
71 if not l.startswith('['):
79 dbg('[%s] %s' % (l, commentary))
84 oc._result = np.reshape(findcurve_result, (3,-1))
86 def point_at_ti(oc, ti):