parent
3f63a4fdbc
commit
15b43bcebf
|
@ -421,16 +421,16 @@ class Rotation:
|
|||
orthonormal = True,
|
||||
reciprocal = False):
|
||||
"""
|
||||
Initialize from tbd.
|
||||
Initialize from lattice basis vectors.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
basis : numpy.ndarray of shape (...,3,3)
|
||||
tbd
|
||||
Three lattice basis vectors in three dimensions.
|
||||
orthonormal : boolean, optional
|
||||
tbd. Defaults to True.
|
||||
Basis is strictly orthonormal, i.e. is free of stretch components. Defaults to True.
|
||||
reciprocal : boolean, optional
|
||||
tbd. Defaults to False.
|
||||
Basis vectors are given in reciprocal (instead of real) space. Defaults to False.
|
||||
|
||||
"""
|
||||
om = np.array(basis,dtype=float)
|
||||
|
@ -452,27 +452,6 @@ class Rotation:
|
|||
|
||||
return Rotation(Rotation._om2qu(om))
|
||||
|
||||
@staticmethod
|
||||
def from_directions(hkl,uvw):
|
||||
"""
|
||||
Initialize from pair of directions/planes.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
hkl: numpy.ndarray of shape (...,3)
|
||||
Direction parallel to z direction, i.e. (h k l) || (0,0,1).
|
||||
uvw: numpy.ndarray of shape (...,3)
|
||||
Direction parallel to x direction, i.e. <u v w> || (1,0,0).
|
||||
|
||||
"""
|
||||
hkl_ = hkl/np.linalg.norm(hkl,axis=-1,keepdims=True)
|
||||
uvw_ = uvw/np.linalg.norm(uvw,axis=-1,keepdims=True)
|
||||
v_1 = np.block([uvw_,np.cross(hkl_,uvw_),hkl_]).reshape(hkl_.shape+(3,))
|
||||
v_2 = np.block([uvw_,np.cross(uvw_,hkl_),hkl_]).reshape(hkl_.shape+(3,))
|
||||
R = np.where(np.broadcast_to(np.expand_dims(np.expand_dims(np.linalg.det(v_1)>0,-1),-1),v_1.shape),
|
||||
v_1,v_2)
|
||||
return Rotation.from_basis(np.swapaxes(R,axis2=-2,axis1=-1))
|
||||
|
||||
@staticmethod
|
||||
def from_matrix(R):
|
||||
"""
|
||||
|
|
|
@ -854,11 +854,6 @@ class TestRotation:
|
|||
rot = Rotation.from_basis(om,False,reciprocal=reciprocal)
|
||||
assert np.isclose(np.linalg.det(rot.as_matrix()),1.0)
|
||||
|
||||
def test_directions(self):
|
||||
hkl = np.array([0.,0.,1.])
|
||||
uvw = np.array([1.,0.,0.])
|
||||
assert np.allclose(Rotation.from_directions(hkl,uvw).as_matrix(),np.eye(3))
|
||||
|
||||
@pytest.mark.parametrize('shape',[None,1,(4,4)])
|
||||
def test_random(self,shape):
|
||||
Rotation.from_random(shape)
|
||||
|
|
Loading…
Reference in New Issue