chiark / gitweb /
introduce MoebiusHalf.normal (nfc)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 6 Nov 2017 13:31:54 +0000 (13:31 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 6 Nov 2017 13:31:54 +0000 (13:31 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
moebius.py

index 3cea68d4f6c2b2145dc89496077ac8a0e0a96f37..ae55a3a74b8843b4e8d4a96bab7c966aa0a9d4a0 100644 (file)
@@ -114,21 +114,27 @@ class MoebiusHalf:
     '''
     return np.array(m._beziers[iu].point_at_t(t))
 
-  def point_offset(m, iu, t, offset):
-    '''
-    offset by offset perpendicular to the surface
-     at the top (iu=t=0), in the y direction
-    '''
+  def normal(m, iu, t):
+    '''at the top (iu=t=0), is +ve in the +ve y direction'''
     p = m.point(iu, t)
     if t == 0:
       dirn = m.edge.dirn(m._thetas[iu], extra_zeta=-tau/4)
     elif iu == m.nu:
-      return m.point_offset(0, t, offset)
+      return m.normal(0, t)
     else:
       vec_t = m.point(iu,   t + 0.01) - p
       vec_u = m.point(iu+1, t)        - p
       dirn =  np.cross(vec_u, vec_t)
-    return p + offset * dirn / np.linalg.norm(dirn)
+      dirn = unit_v(dirn)
+    return dirn
+
+  def point_offset(m, iu, t, offset):
+    '''
+    offset by offset perpendicular to the surface
+     at the top (iu=t=0), +ve offset is in the +ve y direction
+    '''
+    p = m.point(iu, t)
+    return p + offset * m.normal(iu, t)
 
 class Moebius():
   def __init__(m, nv, nw):