class OptimisedCurve():
def __init__(oc, cp, nt):
- db = DiscreteBezier(cp, nt, constructor=BezierSegment)
+ db = DiscreteBezier(cp, nt, bezier_constructor=BezierSegment)
+
fc_input = map(db.point_at_it, range(0, nt+1))
+
for end in (False,True):
- ei = end ? nt : 0
- fi = end ? nt-1 : 1
- cp0i = end ? 0 : 3
- cp1i = end ? 1 : 2
- e = cp[cp0i]
- ef_dirn =unit_v(cp[cp1i] - cp[cp0i])
- ef_len = np.linalg.norm(fc_input[fi] - fc_input[ei])
+ ei = nt if end else 0
+ fi = nt-1 if end else 1
+ cp0i = 0 if end else 3
+ cp1i = 1 if end else 2
+ e = np.array(cp[cp0i])
+ ef_dirn = unit_v(cp[cp1i] - cp[cp0i])
+ ef_len = np.linalg.norm(np.array(fc_input[fi]) - np.array(fc_input[ei]))
f = e + ef_dirn * ef_len
fc_input[ei] = e
fc_input[fi] = f
- findcurve_epsilon = dist_pq_plane * 0.01
+ findcurve_epsilon = 0.01
try:
subproc = findcurve_subprocs[nt]
except KeyError:
- dbg('STARTING FINDCURVE %d' % nt)
+ cl = ['./findcurve', '%d' % nt, '%.18g' % findcurve_epsilon]
+ dbg('STARTING FINDCURVE %s' % cl)
subproc = subprocess.Popen(
- ['./findcurve', '%d' % nt],
+ cl,
bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
findcurve_subprocs[nt] = subproc
- dbg(('RUNNING FINDCURVE')
+ dbg('RUNNING FINDCURVE')
- findcurve_input = np.hstack(*findcurve_input)
- s = ' '.join(map(str, findcurve_input))
+ fc_input = np.hstack(fc_input)
+ s = ' '.join(map(str, fc_input))
dbg(('>> %s' % s))
- print(s, file=findcurve_subproc.stdin)
- findcurve_subproc.stdin.flush()
+ print(s, file=subproc.stdin)
+ subproc.stdin.flush()
commentary = ''
while True:
- l = findcurve_subproc.stdout.readline()
+ l = subproc.stdout.readline()
l = l.rstrip()
dbg('<< ', l)
if not l: vdbg().crashing('findcurve EOF')
oc._result = np.reshape(findcurve_result, (3,-1))
- def point_at_ti(oc, ti):
- return oc._result[ti]
+ def point_at_it(oc, it):
+ return oc._result[it]