chiark / gitweb /
simplex wip: use gsl_vector_get for X, for abandonment
[moebius3.git] / moenp.py
1
2 from __future__ import print_function
3
4 import numpy as np
5
6 tau = np.pi * 2
7
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))
12
13 def unit_v(v):
14   return v / np.linalg.norm(v)
15
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]
19
20 def matmultiply(mat,vect):
21   # both are "array"s
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,:]
25
26 def matmatmultiply(mat1,mat2):
27   # both are "array"s
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)))
31
32 def augmatmultiply(mat,unaugvect, augwith=1):
33   return unaugment(matmultiply(mat, augment(unaugvect, augwith)))
34