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
#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)
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',
from __future__ import print_function
+import moenp
+
_files = []
def dbg_file(f):
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 ]
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)