chiark / gitweb /
more debugging
[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     ps = [ fn(t) for t in np.linspace(0,1,11) ]
23     #dbg('Visdebug', ps)
24     curve(pos = ps, color=color.yellow)
25   def line(vd, p0, p1):
26     vd.curve(lambda t: p0 + t * (p1-p0))
27   def arrow(vd, p, d):
28     vd.line(p, p+d)
29   def crashing(vd, msg):
30     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
31     rate(1E-8)
32
33 dbg_file(sys.stderr)
34 vdbg_enable(Visdebug())
35
36 m = Moebius(nv, nw)
37
38 vs = range(0, nv+1)
39 ws = range(0, nw+1)
40
41 #ts = np.linspace(0, 1, 40)
42
43 #thetas = np.linspace(0, tau, 40)
44 #c0 = curve( color=color.red, pos = [ m.edge.point(th) for th in thetas ] )
45 #c1 = curve( color=color.blue, pos = [ m.midline.point(th) for th in thetas ] )
46
47 for v in vs:
48   c2 = curve( color=color.blue, pos = [ m.point(v,w) for w in ws ] )
49
50 #for w in ws:
51 #  c3 = curve( color=color.blue, pos = [ m.point(v,w) for v in vs ] )
52
53
54 #for v in vs:
55 #  c4 = curve( color=color.blue,
56 #              pos = [ m.point_offset(v,w, 0.1) for w in ws ] )
57
58 #for w in ws:
59 #  c3 = curve( color=(1,0,1), pos = [ m.point_offset(v,w, -0.1) for v in vs ] )
60