From: Ian Jackson Date: Tue, 12 Dec 2017 21:38:17 +0000 (+0000) Subject: move various np stuff into moenp X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=b8e29a1d87fbf060b0d3a843803134102f7fc691;p=moebius3.git move various np stuff into moenp Signed-off-by: Ian Jackson --- diff --git a/helixish.py b/helixish.py index d401efd..61d5b8b 100644 --- a/helixish.py +++ b/helixish.py @@ -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(): diff --git a/moenp.py b/moenp.py index f4f277b..83a1671 100644 --- 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))) +