chiark / gitweb /
vdbg infrastructure
[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():
20   def curve(vd, fn):
21     # fn(t) => 3-tuple, 3-list, or similar, for t \elem [0,1]
22     curve(pos = [ list(fn(t)) for t in np.linspace(0,1,11) ])
23   def crashing(vd, msg):
24     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
25     rate(1E-8)
26
27 dbg_file(sys.stderr)
28 vdbg_enable(Visdebug())
29
30 m = Moebius(nv, nw)
31
32 vs = range(0, nv+1)
33 ws = range(0, nw+1)
34
35 #ts = np.linspace(0, 1, 40)
36
37 #thetas = np.linspace(0, tau, 40)
38 #c0 = curve( color=color.red, pos = [ m.edge.point(th) for th in thetas ] )
39 #c1 = curve( color=color.blue, pos = [ m.midline.point(th) for th in thetas ] )
40
41 for v in vs:
42   c2 = curve( pos = [ m.point(v,w) for w in ws ] )
43
44 for w in ws:
45   c3 = curve( color=color.yellow, pos = [ m.point(v,w) for v in vs ] )
46
47
48 for v in vs:
49   c4 = curve( color=color.blue,
50               pos = [ m.point_offset(v,w, 0.1) for w in ws ] )
51
52 for w in ws:
53   c3 = curve( color=(1,0,1), pos = [ m.point_offset(v,w, -0.1) for v in vs ] )
54