chiark / gitweb /
move various np stuff into moenp
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 12 Dec 2017 21:38:17 +0000 (21:38 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 12 Dec 2017 21:38:17 +0000 (21:38 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
helixish.py
moenp.py

index d401efd837b0195a35cce31e5945a454391456ab..61d5b8b5d3a47c52924b60aa361c7e4029c1c5b8 100644 (file)
@@ -14,25 +14,6 @@ from math import atan2, atan, sqrt
 
 import symbolic
 
-def augment(v, augwith=1): return np.append(v, augwith)
-def augment0(v): return augment(v, 0)
-def unaugment(v): return v[0:3]
-
-def matmultiply(mat,vect):
-  # both are "array"s
-  # we would prefer to write   mat @ vect
-  # but that doesn't work in Python 2
-  return np.array((vect * np.matrix(mat).T))[0,:]
-
-def matmatmultiply(mat1,mat2):
-  # both are "array"s
-  # we would prefer to write   mat1 @ mat2
-  # but that doesn't work in Python 2
-  return np.array((np.matrix(mat1) * np.matrix(mat2)))
-
-def augmatmultiply(mat,unaugvect, augwith=1):
-  return unaugment(matmultiply(mat, augment(unaugvect, augwith)))
-
 findcurve_subproc = None
 
 class HelixishCurve():
index f4f277bf15dde5d4251a1528b15922f07cb45a3f..83a16716aa853d64f3757256a0899bbfd56ddb62 100644 (file)
--- a/moenp.py
+++ b/moenp.py
@@ -12,3 +12,23 @@ unit_z = np.array((0,0,1))
 
 def unit_v(v):
   return v / np.linalg.norm(v)
+
+def augment(v, augwith=1): return np.append(v, augwith)
+def augment0(v): return augment(v, 0)
+def unaugment(v): return v[0:3]
+
+def matmultiply(mat,vect):
+  # both are "array"s
+  # we would prefer to write   mat @ vect
+  # but that doesn't work in Python 2
+  return np.array((vect * np.matrix(mat).T))[0,:]
+
+def matmatmultiply(mat1,mat2):
+  # both are "array"s
+  # we would prefer to write   mat1 @ mat2
+  # but that doesn't work in Python 2
+  return np.array((np.matrix(mat1) * np.matrix(mat2)))
+
+def augmatmultiply(mat,unaugvect, augwith=1):
+  return unaugment(matmultiply(mat, augment(unaugvect, augwith)))
+