chiark / gitweb /
moebius before remove Twirler
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Nov 2017 19:52:20 +0000 (19:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Nov 2017 19:52:20 +0000 (19:52 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
moebius.py [new file with mode: 0644]

diff --git a/moebius.py b/moebius.py
new file mode 100644 (file)
index 0000000..4b4f3a0
--- /dev/null
@@ -0,0 +1,42 @@
+
+import numpy as np
+
+tau = np.pi * 2
+
+origin =  (0,0,0)
+unit_x = (1,0,0)
+unit_y = (0,1,0)
+unit_z = (0,0,1)
+
+def ParametricCircle:
+  def __init__(pc, c, r0, r1):
+    ''' circle centred on c
+        with theta=0 point at c+r0
+        and with theta=tau/4 point at c+r1 '''
+    pc._c  = c
+    pc._r0 = r0
+    pc._r1 = r1
+    pc._axis = np.cross(r0, r1)
+  def point(pc, theta):
+    return pc._c + pc._r0 * cos(theta) + pc._r1 * sin(theta)
+
+def Twirler(ParametricCircle):
+  def __init__(tw, c, r0, r1, cycles, begin):
+    ''' circle centred on c, etc.
+        but with an orientation at each point, orthogonal to
+        the circle
+'''
+    ParametricCircle.__init__(tw, c, r0, r1)
+    tw._cycles = cycles
+  def 
+
+class Moebius:
+  def __init__(m, n_u):
+    m._edge = ParametricCircle(origin, unit_z, unit_x)
+    m._midline = ParametricCircle(-unit_z, unit_z, unit_y)
+    m._beziers = [ self._bezier(u) for u in np.linspace(0, 1, n_u) ]
+  def _bezier(u):
+    theta = u * tau
+    cp0 = m._edge.point(theta)
+    cp3 = m._midline.point(theta*2)
+