chiark / gitweb /
helixish: bugfixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Nov 2017 14:34:42 +0000 (14:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Nov 2017 14:34:42 +0000 (14:34 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
helixish.py
symbolic.py

index d7b1445502afdd64573d26ce29f774c08ffbb718..d1f9ff6f0fb4cd0a9d15308bbc4611c32ac4b3e6 100644 (file)
@@ -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)
index f787079f9f0356510d3e56718bc23ec82de51ace..611bbd575fedc228c05bd14f57fe996ff025bf95 100644 (file)
@@ -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)