2 from __future__ import print_function
8 origin = np.array((0,0,0))
9 unit_x = np.array((1,0,0))
10 unit_y = np.array((0,1,0))
11 unit_z = np.array((0,0,1))
14 return v / np.linalg.norm(v)
16 def augment(v, augwith=1): return np.append(v, augwith)
17 def augment0(v): return augment(v, 0)
18 def unaugment(v): return v[0:3]
20 def matmultiply(mat,vect):
22 # we would prefer to write mat @ vect
23 # but that doesn't work in Python 2
24 return np.array((vect * np.matrix(mat).T))[0,:]
26 def matmatmultiply(mat1,mat2):
28 # we would prefer to write mat1 @ mat2
29 # but that doesn't work in Python 2
30 return np.array((np.matrix(mat1) * np.matrix(mat2)))
32 def augmatmultiply(mat,unaugvect, augwith=1):
33 return unaugment(matmultiply(mat, augment(unaugvect, augwith)))