chiark / gitweb /
helixish: attempt at the whole thing
[moebius3.git] / visual
diff --git a/visual b/visual
index a6f78c47da4132c912cec8eb9bb53561c6b1cb7e..d623bfb6c14f42f5ea9c2f6097ebd22a9927610e 100755 (executable)
--- a/visual
+++ b/visual
@@ -10,24 +10,37 @@ from bezier import BezierSegment
 import numpy as np
 import sys
 
+scene.width = 1200
+scene.height = 1200
+scene.fov = 1E-3
+
 from moebius import *
 from moedebug import *
 
-nv = 40
-nw = 40
+nv = 20
+nw = 80
 
-class Visdebug():
-  def curve(vd, fn):
+class Visdebug(BaseVisdebug):
+  def curve(vd, fn, color=color.yellow):
     # fn(t) => 3-tuple, 3-list, or similar, for t \elem [0,1]
     ps = [ fn(t) for t in np.linspace(0,1,11) ]
     #dbg('Visdebug', ps)
-    curve(pos = ps)
+    curve(pos = ps, color=color)
+  def circle(vd, c, axis, **kw):
+    ring(pos=c, axis=axis, radius=np.linalg.norm(axis), thickness=0.005, **kw)
+  def arrow(vd, p, d, **kw):
+    print('arrow %s' % repr(kw), file=sys.stderr)
+    bodge_color = kw.get('color', (1,0,0))
+    try: del kw['color']
+    except KeyError: pass
+    vd.line(p, p+d, color=bodge_color, **kw)
+    vd.circle(p, np.asarray(d) * 0.25, color=bodge_color, **kw)
   def crashing(vd, msg):
     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
     rate(1E-8)
 
 dbg_file(sys.stderr)
-vdbg_enable(Visdebug())
+#vdbg_enable(Visdebug())
 
 m = Moebius(nv, nw)
 
@@ -40,17 +53,19 @@ ws = range(0, nw+1)
 #c0 = curve( color=color.red, pos = [ m.edge.point(th) for th in thetas ] )
 #c1 = curve( color=color.blue, pos = [ m.midline.point(th) for th in thetas ] )
 
-for v in vs:
-  c2 = curve( pos = [ m.point(v,w) for w in ws ] )
+for vi in range(0, len(vs)):
+  v= vs[vi]
+  c2 = curve( color= (color.blue if vi == int(2*nv/3) else (0,0,0.5)),
+              pos = [ m.point(v,w) for w in ws ] )
 
-for w in ws:
-  c3 = curve( color=color.yellow, pos = [ m.point(v,w) for v in vs ] )
+#for w in ws:
+#  c3 = curve( color=color.blue, pos = [ m.point(v,w) for v in vs ] )
 
 
-for v in vs:
-  c4 = curve( color=color.blue,
-              pos = [ m.point_offset(v,w, 0.1) for w in ws ] )
+#for v in vs:
+#  c4 = curve( color=color.blue,
+#              pos = [ m.point_offset(v,w, 0.1) for w in ws ] )
 
-for w in ws:
-  c3 = curve( color=(1,0,1), pos = [ m.point_offset(v,w, -0.1) for v in vs ] )
+#for w in ws:
+#  c3 = curve( color=(1,0,1), pos = [ m.point_offset(v,w, -0.1) for v in vs ] )