chiark / gitweb /
helixish: debugging output
[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 scene.width = 1200
14 scene.height = 1200
15 scene.fov = 1E-3
16
17 from moebius import *
18 from moedebug import *
19
20 nv = 40
21 nw = 40
22
23 class Visdebug(BaseVisdebug):
24   def curve(vd, fn, colour=color.yellow):
25     # fn(t) => 3-tuple, 3-list, or similar, for t \elem [0,1]
26     ps = [ fn(t) for t in np.linspace(0,1,11) ]
27     #dbg('Visdebug', ps)
28     curve(pos = ps, color=colour)
29   def arrow(vd, p, d, **kw):
30     vd.line(p, p+d, **kw)
31     ring(pos=p, axis=d, radius=0.25, thickness=0.005, **kw)
32   def crashing(vd, msg):
33     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
34     rate(1E-8)
35
36 dbg_file(sys.stderr)
37 vdbg_enable(Visdebug())
38
39 m = Moebius(nv, nw)
40
41 vs = range(0, nv+1)
42 ws = range(0, nw+1)
43
44 #ts = np.linspace(0, 1, 40)
45
46 #thetas = np.linspace(0, tau, 40)
47 #c0 = curve( color=color.red, pos = [ m.edge.point(th) for th in thetas ] )
48 #c1 = curve( color=color.blue, pos = [ m.midline.point(th) for th in thetas ] )
49
50 for v in vs:
51   c2 = curve( color=color.blue, pos = [ m.point(v,w) for w in ws ] )
52
53 #for w in ws:
54 #  c3 = curve( color=color.blue, pos = [ m.point(v,w) for v in vs ] )
55
56
57 #for v in vs:
58 #  c4 = curve( color=color.blue,
59 #              pos = [ m.point_offset(v,w, 0.1) for w in ws ] )
60
61 #for w in ws:
62 #  c3 = curve( color=(1,0,1), pos = [ m.point_offset(v,w, -0.1) for v in vs ] )
63