From: Ian Jackson Date: Sun, 26 Nov 2017 14:34:42 +0000 (+0000) Subject: helixish: bugfixes X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=69a84b4bca382a3c177c83a8ea34259e4e00a0d9;p=moebius3.git helixish: bugfixes Signed-off-by: Ian Jackson --- diff --git a/helixish.py b/helixish.py index d7b1445..d1f9ff6 100644 --- a/helixish.py +++ b/helixish.py @@ -5,7 +5,7 @@ import numpy as np from numpy import cos, sin import sys -from moebdebug import dbg +from moedebug import dbg from moenp import * import symbolic @@ -39,7 +39,7 @@ class HelixishCurve(): # but minimum is 10% of (wlog) {s,t} [[ not quite like this ]] dPQplane_normal = np.cross(dp, dq) - if (np.norm(dPQplane_normal) < 1E6): + if (np.linalg.norm(dPQplane_normal) < 1E6): dPQplane_normal += [0, 0, 1E5] dPQplane_normal = unit_v(dPQplane_normal) @@ -140,7 +140,7 @@ class HelixishCurve(): findcurve_input = np.hstack((findcurve_target, findcurve_start, - [findcurve_epsilon]))) + [findcurve_epsilon])) dbg('RUNNING FINDCURVE', *findcurve_input) print(findcurve_subproc.stdin, *findcurve_input) findcurve_subproc.stdin.flush() @@ -151,6 +151,18 @@ class HelixishCurve(): dbg('GOT ', l) l = eval(l) if l is None: break - findcurve_result = l[0:5] - symbolic.get_python(something) + hc.findcurve_result = l[0:5] + hc.func = symbolic.get_python(something) + hc.threshold = l[0]**2 + hc.total_dist = hc.threshold + l[1]**2 + + def point_at_t(hc, normalised_parameter): + dist = normalised_parameter * hc.total_dist + ours = [p for p in findcurve_result] + if dist <= hc.threshold: + ours[0] = sqrt(dist) + ours[1] = 0 + else: + ours[1] = sqrt(dist - hc.threshold) + return hc.func(*ours) diff --git a/symbolic.py b/symbolic.py index f787079..611bbd5 100644 --- a/symbolic.py +++ b/symbolic.py @@ -248,5 +248,4 @@ def get_python(): sinc_fixed = Function('sinc_fixed') implemented_function(sinc_fixed, lambda x: np.sinc(x/np.pi)) p = list(map(eval,params)) - p.append(s) return lambdify(p, q_sqparm)