chiark
/
gitweb
/
~ian
/
moebius3.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
visual: debugging changes
[moebius3.git]
/
helixish.py
diff --git
a/helixish.py
b/helixish.py
index 971c896266b9bd1290002ca1279132cbdf9bf284..d583421dc709602c9cba41aabed33ecc5df53d17 100644
(file)
--- a/
helixish.py
+++ b/
helixish.py
@@
-28,8
+28,8
@@
class HelixishCurve():
dbg('HelixishCurve __init__', cp)
dbg(dp, dq)
dbg('HelixishCurve __init__', cp)
dbg(dp, dq)
-
#
vdbg().arrow(p,dp)
-
#
vdbg().arrow(q,dq)
+ vdbg().arrow(p,dp)
+ vdbg().arrow(q,dq)
# the initial attempt
# - solve in the plane containing dP and dQ
# the initial attempt
# - solve in the plane containing dP and dQ
@@
-72,14
+72,14
@@
class HelixishCurve():
dp_plane = augmatmultiply(dPQplane_into, dp, augwith=0)
dq_plane = augmatmultiply(dPQplane_into, dq, augwith=0)
q_plane = augmatmultiply(dPQplane_into, q)
dp_plane = augmatmultiply(dPQplane_into, dp, augwith=0)
dq_plane = augmatmultiply(dPQplane_into, dq, augwith=0)
q_plane = augmatmultiply(dPQplane_into, q)
- dist_pq_plane = np.linalg.norm(q_plane)
+ dist_pq_plane = np.linalg.norm(q_plane
[0:2]
)
vdbg_plane = MatrixVisdebug(vdbg(), dPQplane_basis)
dbg('plane p', p_plane_check, 'dp', dp_plane, 'dq', dq_plane,
'q', q_plane, 'dist_pq_plane', dist_pq_plane)
vdbg_plane = MatrixVisdebug(vdbg(), dPQplane_basis)
dbg('plane p', p_plane_check, 'dp', dp_plane, 'dq', dq_plane,
'q', q_plane, 'dist_pq_plane', dist_pq_plane)
- vdbg_plane.arrow(p_plane_check, dp_plane)
- vdbg_plane.arrow(q_plane, dq_plane)
+
#
vdbg_plane.arrow(p_plane_check, dp_plane)
+
#
vdbg_plane.arrow(q_plane, dq_plane)
railway_inplane_basis_x = np.hstack((q_plane[0:2], [0]))
railway_inplane_basis = np.column_stack((
railway_inplane_basis_x = np.hstack((q_plane[0:2], [0]))
railway_inplane_basis = np.column_stack((
@@
-94,7
+94,7
@@
class HelixishCurve():
dbg('railway_inplane_basis\n', railway_inplane_basis)
railway_basis = matmatmultiply(dPQplane_basis, railway_inplane_basis)
dbg('railway_basis\n', railway_basis)
dbg('railway_inplane_basis\n', railway_inplane_basis)
railway_basis = matmatmultiply(dPQplane_basis, railway_inplane_basis)
dbg('railway_basis\n', railway_basis)
- vdbg().basis(railway_basis, hue=(1,0,1))
+
#
vdbg().basis(railway_basis, hue=(1,0,1))
vdbg_railway = MatrixVisdebug(vdbg(), railway_basis)
# two circular arcs of equal maximum possible radius
vdbg_railway = MatrixVisdebug(vdbg(), railway_basis)
# two circular arcs of equal maximum possible radius
@@
-110,7
+110,8
@@
class HelixishCurve():
dbg('railway:', railway_theta, railway_phi, railway_angleoffset)
def vdbg_railway_angle(start, angle, **kw):
dbg('railway:', railway_theta, railway_phi, railway_angleoffset)
def vdbg_railway_angle(start, angle, **kw):
- vdbg_railway.arrow(start, [sin(angle), cos(angle), 0], **kw)
+ #vdbg_railway.arrow(start, [sin(angle), cos(angle), 0], **kw)
+ pass
vdbg_railway_angle([0, 0, 0.1], railway_theta, color=(1, 0.5, 0))
vdbg_railway_angle([1, 0, 0.1], railway_phi, color=(1, 0.5, 0))
vdbg_railway_angle([1, 0, 0.1], 0, color=(1, 1.00, 0))
vdbg_railway_angle([0, 0, 0.1], railway_theta, color=(1, 0.5, 0))
vdbg_railway_angle([1, 0, 0.1], railway_phi, color=(1, 0.5, 0))
vdbg_railway_angle([1, 0, 0.1], 0, color=(1, 1.00, 0))
@@
-124,6
+125,11
@@
class HelixishCurve():
]
railway_roots = np.roots(railway_polynomial)
dbg('railway poly, roots:', railway_polynomial, railway_roots)
]
railway_roots = np.roots(railway_polynomial)
dbg('railway poly, roots:', railway_polynomial, railway_roots)
+
+ #vdbg_railway.circle([0,0,0], [0,0, dist_pq_plane], color=(.5,0,0))
+ #vdbg_railway.circle([1,0,0], [0,0, 0.05], color=(.5,0,0))
+ #vdbg().circle(p, dPQplane_normal * dist_pq_plane, color=(.5,.5,0))
+
for railway_r_pq1 in railway_roots:
# roots for r are calculated based on coordinates where
# Q is at (1,0) but our PQ distance is different
for railway_r_pq1 in railway_roots:
# roots for r are calculated based on coordinates where
# Q is at (1,0) but our PQ distance is different
@@
-134,34
+140,40
@@
class HelixishCurve():
railway_polynomial[2]
)
railway_polynomial[2]
)
+ #vdbg_railway.circle([0,0,0], [0,0, railway_r], color=(1,0,0))
+ #vdbg().circle(p, dPQplane_normal * railway_r, color=(1,1,0))
+
def railway_CPQ(pq, dpq, railway_r):
CPQ = pq + railway_r * np.array([-dpq[1], dpq[0]])
dbg('railway_CPQ', railway_r, pq, dpq, CPQ)
def railway_CPQ(pq, dpq, railway_r):
CPQ = pq + railway_r * np.array([-dpq[1], dpq[0]])
dbg('railway_CPQ', railway_r, pq, dpq, CPQ)
- vdbg_plane.circle( np.hstack((CPQ, [0])),
- [0, 0, railway_r],
- color = (1,1,1) )
+ #vdbg_plane.circle( np.hstack((CPQ, [0])),
+ # [0, 0, railway_r],
+ # color = (1,1,1) )
+ #vdbg_plane.circle( np.hstack(( 2*np.asarray(pq) - CPQ, [0])),
+ # [0, 0, railway_r],
+ # color = (.5,.5,.5) )
return CPQ
railway_CP = railway_CPQ([0,0], dp_plane, railway_r)
return CPQ
railway_CP = railway_CPQ([0,0], dp_plane, railway_r)
- railway_
QP
= railway_CPQ(q_plane[0:2], -dq_plane, railway_r)
- railway_midpt = 0.5 * (railway_CP + railway_
QP
)
+ railway_
CQ
= railway_CPQ(q_plane[0:2], -dq_plane, railway_r)
+ railway_midpt = 0.5 * (railway_CP + railway_
CQ
)
best_st = None
def railway_ST(C, start, end, railway_r):
delta = atan2(*(end - C)[0:2]) - atan2(*(start - C)[0:2])
best_st = None
def railway_ST(C, start, end, railway_r):
delta = atan2(*(end - C)[0:2]) - atan2(*(start - C)[0:2])
+ dbg('railway_ST C', C, 'start', start, 'end', end, 'delta', delta)
+ if delta < 0: delta += tau
s = delta * railway_r
s = delta * railway_r
- dbg('railway_ST
', C, start, end, railway_r
, s)
+ dbg('railway_ST
delta', delta, 'r', railway_r, 's'
, s)
return s
return s
- try_s = railway_ST(railway_CP,
[0,0], railway_midpt
, railway_r)
- try_t = railway_ST(railway_C
P
, railway_midpt, q_plane[0:2], railway_r)
+ try_s = railway_ST(railway_CP,
railway_midpt, [0,0]
, railway_r)
+ try_t = railway_ST(railway_C
Q
, railway_midpt, q_plane[0:2], railway_r)
dbg('try_s, _t', try_s, try_t)
dbg('try_s, _t', try_s, try_t)
- if try_s < 0 or try_t < 0:
- continue
try_st = try_s + try_t
if best_st is None or try_st < best_st:
try_st = try_s + try_t
if best_st is None or try_st < best_st:
- start_la = 1/railway_r
+ start_la =
-
1/railway_r
start_s = try_s
start_t = try_t
best_st = try_st
start_s = try_s
start_t = try_t
best_st = try_st
@@
-241,6
+253,7
@@
class HelixishCurve():
findcurve_subproc.stdin.flush()
hc.func = symbolic.get_python()
findcurve_subproc.stdin.flush()
hc.func = symbolic.get_python()
+ hc.findcurve_basis = findcurve_basis
commentary = ''
while True:
commentary = ''
while True:
@@
-262,6
+275,7
@@
class HelixishCurve():
commentary = ''
hc.findcurve_result = l[0:6]
commentary = ''
hc.findcurve_result = l[0:6]
+ #hc.findcurve_result = findcurve_start
hc.threshold = l[0]**2
hc.total_dist = hc.threshold + l[1]**2
#vdbg().curve( hc.point_at_t )
hc.threshold = l[0]**2
hc.total_dist = hc.threshold + l[1]**2
#vdbg().curve( hc.point_at_t )
@@
-276,4
+290,5
@@
class HelixishCurve():
ours[1] = sqrt(dist - hc.threshold)
asmat = hc.func(*ours)
p = asmat[:,0]
ours[1] = sqrt(dist - hc.threshold)
asmat = hc.func(*ours)
p = asmat[:,0]
+ p = augmatmultiply(hc.findcurve_basis, p)
return p
return p