chiark / gitweb /
more debugging
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Dec 2017 00:07:39 +0000 (00:07 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 13 Dec 2017 00:07:39 +0000 (00:07 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
helixish.py
moedebug.py
visual

index aca4a237ae2d6cb273aa66dcf3537f607db01e93..3bb589338ad035af0144453bb6ccc11a53fd6227 100644 (file)
@@ -25,12 +25,12 @@ class HelixishCurve():
     dp = unit_v(cp[1]-cp[0])
     dq = unit_v(cp[3]-cp[2])
 
-    vdbg().arrow(p,dp)
-    vdbg().arrow(q,dq)
-
     dbg('HelixishCurve __init__', cp)
     dbg(dp, dq)
 
+    #vdbg().arrow(p,dp)
+    #vdbg().arrow(q,dq)
+
     # the initial attempt
     #   - solve in the plane containing dP and dQ
     #   - total distance normal to that plane gives mu
@@ -60,6 +60,10 @@ class HelixishCurve():
     #dbg(dPQplane_basis)
     dPQplane_basis = np.vstack((dPQplane_basis, [0,0,0,1]))
     dbg(dPQplane_basis)
+
+    #for ax in range(0,3):
+    #  vdbg().arrow(dPQplane_basis[0:3,3], dPQplane_basis[0:3,ax])
+
     dPQplane_into = np.linalg.inv(dPQplane_basis)
     dbg(dPQplane_into)
 
@@ -69,7 +73,11 @@ class HelixishCurve():
     q_plane  = augmatmultiply(dPQplane_into, q)
     dist_pq_plane = np.linalg.norm(q_plane)
 
+    vdbg_plane = MatrixVisdebug(vdbg(), dPQplane_basis)
+
     dbg('plane:', p_plane_check, dp_plane, dq_plane, q_plane)
+    vdbg_plane.arrow(p_plane_check, dp_plane)
+    vdbg_plane.arrow(q_plane,       dq_plane)
 
     # two circular arcs of equal maximum possible radius
     # algorithm courtesy of Simon Tatham (`Railway problem',
index 97e8635f16d90e9f02d780b5bbec52fc1d998a6e..f9f85618d50f6a1c1a7f17b165a9bad6df0ff573 100644 (file)
@@ -1,6 +1,8 @@
 
 from __future__ import print_function
 
+import moenp
+
 _files = []
 
 def dbg_file(f):
@@ -16,12 +18,26 @@ def dbg(*args):
       print('// D ', l, file=f)
     f.flush()
 
+class BaseVisdebug():
+  def line(vd, p0, p1):
+    vd.curve(lambda t: p0 + t * (p1-p0))
+  def arrow(vd, p, d):
+    vd.line(p, p+d)
+
 class NullVisdebug():
   def curve(*a, **kw): pass
   def line(*a, **kw): pass
   def arrow(*a, **kw): pass
   def crashing(*a, **kw): pass
 
+class MatrixVisdebug(BaseVisdebug):
+  def __init__(m, base, matrix):
+    m._b = base
+    m._matrix = matrix
+  def curve(m, fn):
+    m._b.curve(lambda t: moenp.augmatmultiply(m._matrix, fn(t)))
+  def crashing(m, *a, **kw): m._b.crashing(*a, **kw)
+
 _nullvis = NullVisdebug()
 _vis = [ _nullvis ]
 
diff --git a/visual b/visual
index 90ad5c3bdbfe99281bf69f94553eaab142701c95..dcb57e1a573ef3da001f9ee2cedcd2b30d0cdfcd 100755 (executable)
--- a/visual
+++ b/visual
@@ -16,16 +16,12 @@ from moedebug import *
 nv = 40
 nw = 40
 
-class Visdebug():
+class Visdebug(BaseVisdebug):
   def curve(vd, fn):
     # fn(t) => 3-tuple, 3-list, or similar, for t \elem [0,1]
     ps = [ fn(t) for t in np.linspace(0,1,11) ]
     #dbg('Visdebug', ps)
     curve(pos = ps, color=color.yellow)
-  def line(vd, p0, p1):
-    vd.curve(lambda t: p0 + t * (p1-p0))
-  def arrow(vd, p, d):
-    vd.line(p, p+d)
   def crashing(vd, msg):
     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
     rate(1E-8)