.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/rotations/rotating_z_to_high_symmetry_directions.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:Go to the end  to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_rotations_rotating_z_to_high_symmetry_directions.py: ===================================================== Rotating z-vector to high-symmetry crystal directions ===================================================== This example shows how to sample high-symmetry crystal directions :math:\mathbf{t} = [u, v, w] (or zone axes) using :meth:orix.vector.Miller.from_highest_indices. We will also return the rotations :math:R which rotate :math:\mathbf{v_z} = (0, 0, 1) to :math:\mathbf{t}. We do the following to obtain the high-symmetry crystal directions: 1. Select a point group, here :math:S = mmm. 2. Sample all directions :math:\mathbf{t_i} with indices of -1, 0, and 1 3. Project :math:\mathbf{t_i} to the fundamental sector of the Laue group of :math:S (which in this case is itself) 4. Discard symmetrically equivalent and other duplicate crystal directions. Vectors such as [001] and [002] are considered equal after we make them unit vectors. 5. Round the vector indices to the closest smallest integer (below a default of 20). The rotations :math:R can be useful e.g. when simulating diffraction patterns from crystals with one of the high-symmetry zone axes :math:\mathbf{t} aligned along the beam path. .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: Python from orix.crystal_map import Phase from orix.quaternion import Rotation from orix.vector import Miller, Vector3d phase = Phase(point_group="mmm") t = Miller.from_highest_indices(phase, uvw=[1, 1, 1]) t = t.in_fundamental_sector() t = t.unit.unique(use_symmetry=True).round() print(t) .. rst-class:: sphx-glr-script-out .. code-block:: none Miller (7,), point group mmm, uvw [[0. 0. 1.] [0. 1. 1.] [0. 1. 0.] [1. 1. 1.] [1. 0. 1.] [1. 1. 0.] [1. 0. 0.]] .. GENERATED FROM PYTHON SOURCE LINES 38-40 Get the rotations that rotate :math:\mathbf{v_z} to these crystal directions .. GENERATED FROM PYTHON SOURCE LINES 40-46 .. code-block:: Python vz = Miller(uvw=[0, 0, 1], phase=t.phase) R = Rotation.identity(t.size) for i, t_i in enumerate(t): R[i] = Rotation.from_align_vectors(t_i, vz) print(R) .. rst-class:: sphx-glr-script-out .. code-block:: none Rotation (7,) [[ 1. 0. 0. 0. ] [ 0.9239 -0.3827 0. 0. ] [ 0.7071 -0.7071 0. 0. ] [ 0.8881 -0.3251 0.3251 0. ] [ 0.9239 0. 0.3827 0. ] [ 0.7071 -0.5 0.5 0. ] [ 0.7071 0. 0.7071 0. ]] .. GENERATED FROM PYTHON SOURCE LINES 47-49 Plot the crystal directions within the fundamental sector of Laue group :math:mmm .. GENERATED FROM PYTHON SOURCE LINES 49-60 .. code-block:: Python fig = t.scatter( vector_labels=[str(vi).replace(".", "") for vi in t.coordinates], text_kwargs={ "size": 15, "offset": (0, 0.03), "bbox": {"fc": "w", "pad": 2, "alpha": 0.75}, }, return_figure=True, ) fig.axes[0].restrict_to_sector(t.phase.point_group.fundamental_sector) .. image-sg:: /examples/rotations/images/sphx_glr_rotating_z_to_high_symmetry_directions_001.png :alt: rotating z to high symmetry directions :srcset: /examples/rotations/images/sphx_glr_rotating_z_to_high_symmetry_directions_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.979 seconds) **Estimated memory usage:** 9 MB .. _sphx_glr_download_examples_rotations_rotating_z_to_high_symmetry_directions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:Download Jupyter notebook: rotating_z_to_high_symmetry_directions.ipynb  .. container:: sphx-glr-download sphx-glr-download-python :download:Download Python source code: rotating_z_to_high_symmetry_directions.py  .. only:: html .. rst-class:: sphx-glr-signature Gallery generated by Sphinx-Gallery _