chiark / gitweb /
visual: debug arrows better
[moebius3.git] / visual
1 #!/usr/bin/python
2
3 from __future__ import print_function
4
5 import signal
6 signal.signal(signal.SIGINT, signal.SIG_DFL)
7
8 from visual import *
9 from bezier import BezierSegment
10 import numpy as np
11 import sys
12
13 from moebius import *
14 from moedebug import *
15
16 nv = 40
17 nw = 40
18
19 class Visdebug(BaseVisdebug):
20   def curve(vd, fn, colour=color.yellow):
21     # fn(t) => 3-tuple, 3-list, or similar, for t \elem [0,1]
22     ps = [ fn(t) for t in np.linspace(0,1,11) ]
23     #dbg('Visdebug', ps)
24     curve(pos = ps, color=colour)
25   def arrow(vd, p, d, **kw):
26     vd.line(p, p+d, **kw)
27     ring(pos=p, axis=d, radius=0.25, thickness=0.005, **kw)
28   def crashing(vd, msg):
29     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
30     rate(1E-8)
31
32 dbg_file(sys.stderr)
33 vdbg_enable(Visdebug())
34
35 m = Moebius(nv, nw)
36
37 vs = range(0, nv+1)
38 ws = range(0, nw+1)
39
40 #ts = np.linspace(0, 1, 40)
41
42 #thetas = np.linspace(0, tau, 40)
43 #c0 = curve( color=color.red, pos = [ m.edge.point(th) for th in thetas ] )
44 #c1 = curve( color=color.blue, pos = [ m.midline.point(th) for th in thetas ] )
45
46 for v in vs:
47   c2 = curve( color=color.blue, pos = [ m.point(v,w) for w in ws ] )
48
49 #for w in ws:
50 #  c3 = curve( color=color.blue, pos = [ m.point(v,w) for v in vs ] )
51
52
53 #for v in vs:
54 #  c4 = curve( color=color.blue,
55 #              pos = [ m.point_offset(v,w, 0.1) for w in ws ] )
56
57 #for w in ws:
58 #  c3 = curve( color=(1,0,1), pos = [ m.point_offset(v,w, -0.1) for v in vs ] )
59