From 54d8545da4e53c644c3a91a6961c42e7ed43ed09 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 13 Dec 2017 00:07:39 +0000 Subject: [PATCH] more debugging Signed-off-by: Ian Jackson --- helixish.py | 14 +++++++++++--- moedebug.py | 16 ++++++++++++++++ visual | 6 +----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/helixish.py b/helixish.py index aca4a23..3bb5893 100644 --- a/helixish.py +++ b/helixish.py @@ -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', diff --git a/moedebug.py b/moedebug.py index 97e8635..f9f8561 100644 --- a/moedebug.py +++ b/moedebug.py @@ -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 90ad5c3..dcb57e1 100755 --- 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) -- 2.30.2