diff --git a/diffsims/crystallography/reciprocal_lattice_vector.py b/diffsims/crystallography/reciprocal_lattice_vector.py index d52f4e24..b424c0d7 100644 --- a/diffsims/crystallography/reciprocal_lattice_vector.py +++ b/diffsims/crystallography/reciprocal_lattice_vector.py @@ -503,21 +503,6 @@ def scattering_parameter(self): return 0.5 * self.gspacing - def rotate_from_matrix(self, rotation_matrix): - """Rotate the reciprocal lattice vectors using a (3x3) rotation matrix. - - This method creates a new instance of :class:`ReciprocalLatticeVector` - with the rotated vectors. - - Parameters - ---------- - rotation_matrix : numpy.ndarray - (3, 3) rotation matrix. - """ - return ReciprocalLatticeVector( - phase=self.phase, xyz=np.matmul(rotation_matrix.T, self.data.T).T - ) - @property def structure_factor(self): r"""Kinematical structure factors :math:`F`. diff --git a/diffsims/generators/simulation_generator.py b/diffsims/generators/simulation_generator.py index 0d7c3e2a..bd598116 100644 --- a/diffsims/generators/simulation_generator.py +++ b/diffsims/generators/simulation_generator.py @@ -196,7 +196,7 @@ def calculate_diffraction2d( include_zero_vector=with_direct_beam, ) phase_vectors = [] - for rot in rotate.to_matrix(): + for rot in rotate: # Calculate the reciprocal lattice vectors that intersect the Ewald sphere. ( intersected_vectors, @@ -335,7 +335,7 @@ def calculate_diffraction1d( def get_intersecting_reflections( self, recip: ReciprocalLatticeVector, - rot: np.ndarray, + rot: Rotation, wavelength: float, max_excitation_error: float, shape_factor_width: float = None, @@ -348,7 +348,8 @@ def get_intersecting_reflections( recip The reciprocal lattice vectors to rotate. rot - The rotation matrix to apply to the reciprocal lattice vectors. + The rotation to apply to the reciprocal lattice vectors. + Orix conventions apply, i.e. "lab2crystal". wavelength The wavelength of the electrons in Angstroms. max_excitation_error @@ -361,13 +362,14 @@ def get_intersecting_reflections( control. If not set will be set equal to max_excitation_error. """ initial_hkl = recip.hkl - rotated_vectors = recip.rotate_from_matrix(rot) + # To ease calculations, we transform the reciprocal lattice vectors rather than the electron beam. + # Therefore, we need to invert the rotation, as it normally transforms the beam (lab2crystal). + rotated_vectors = (~rot * recip.to_miller()).data if with_direct_beam: - rotated_vectors = np.vstack([rotated_vectors.data, [0, 0, 0]]) + rotated_vectors = np.vstack([rotated_vectors, [0, 0, 0]]) initial_hkl = np.vstack([initial_hkl, [0, 0, 0]]) - else: - rotated_vectors = rotated_vectors.data + # Identify the excitation errors of all points (distance from point to Ewald sphere) r_sphere = 1 / wavelength r_spot = np.sqrt(np.sum(np.square(rotated_vectors[:, :2]), axis=1))