transparent (3,3) reshape of matrix when generating orientation.

This commit is contained in:
Philip Eisenlohr 2015-05-27 18:56:18 +00:00
parent 90bb2f2b2f
commit 58eb4fc301
1 changed files with 13 additions and 10 deletions

View File

@ -432,6 +432,9 @@ class Quaternion:
@classmethod @classmethod
def fromMatrix(cls, m): def fromMatrix(cls, m):
if m.shape != (3,3) and np.prod(m.shape) == 9:
m = m.reshape(3,3)
tr=m[0,0]+m[1,1]+m[2,2] tr=m[0,0]+m[1,1]+m[2,2]
if tr > 0.00000001: if tr > 0.00000001:
s = math.sqrt(tr + 1.0)*2.0 s = math.sqrt(tr + 1.0)*2.0
@ -710,9 +713,9 @@ class Symmetry:
[ 1., 0., 0.], [ 1., 0., 0.],
[ 0., 1., 0.] ]) [ 0., 1., 0.] ])
else: else:
basis = None basis = np.zeros((3,3),dtype=float)
if basis == None: if np.all(basis == 0.0):
theComponents = -np.ones(3,'d') theComponents = -np.ones(3,'d')
else: else:
theComponents = np.dot(basis,np.array([vector[0],vector[1],abs(vector[2])])) theComponents = np.dot(basis,np.array([vector[0],vector[1],abs(vector[2])]))