transparent (3,3) reshape of matrix when generating orientation.
This commit is contained in:
parent
90bb2f2b2f
commit
58eb4fc301
|
@ -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
|
||||||
|
@ -681,17 +684,17 @@ class Symmetry:
|
||||||
Return inverse pole figure color if requested.
|
Return inverse pole figure color if requested.
|
||||||
'''
|
'''
|
||||||
# basis = {'cubic' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
# basis = {'cubic' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
||||||
# [1.,0.,1.]/np.sqrt(2.), # direction of green
|
# [1.,0.,1.]/np.sqrt(2.), # direction of green
|
||||||
# [1.,1.,1.]/np.sqrt(3.)]).transpose()), # direction of blue
|
# [1.,1.,1.]/np.sqrt(3.)]).transpose()), # direction of blue
|
||||||
# 'hexagonal' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
# 'hexagonal' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
||||||
# [1.,0.,0.], # direction of green
|
# [1.,0.,0.], # direction of green
|
||||||
# [np.sqrt(3.),1.,0.]/np.sqrt(4.)]).transpose()), # direction of blue
|
# [np.sqrt(3.),1.,0.]/np.sqrt(4.)]).transpose()), # direction of blue
|
||||||
# 'tetragonal' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
# 'tetragonal' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
||||||
# [1.,0.,0.], # direction of green
|
# [1.,0.,0.], # direction of green
|
||||||
# [1.,1.,0.]/np.sqrt(2.)]).transpose()), # direction of blue
|
# [1.,1.,0.]/np.sqrt(2.)]).transpose()), # direction of blue
|
||||||
# 'orthorhombic' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
# 'orthorhombic' : np.linalg.inv(np.array([[0.,0.,1.], # direction of red
|
||||||
# [1.,0.,0.], # direction of green
|
# [1.,0.,0.], # direction of green
|
||||||
# [0.,1.,0.]]).transpose()), # direction of blue
|
# [0.,1.,0.]]).transpose()), # direction of blue
|
||||||
# }
|
# }
|
||||||
if self.lattice == 'cubic':
|
if self.lattice == 'cubic':
|
||||||
basis = np.array([ [-1. , 0. , 1. ],
|
basis = np.array([ [-1. , 0. , 1. ],
|
||||||
|
@ -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])]))
|
||||||
|
|
Loading…
Reference in New Issue