.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/rotations/rotations_mapping_fundamental_sector.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_rotations_mapping_fundamental_sector.py: ================================================ Rotations mapping the fundamental sector on *S2* ================================================ This example shows how to sample rotations :math:`\mathbf{R}` that when rotating the vector :math:`\mathbf{v_z} = (0, 0, 1)`, the resulting vectors cover the fundamental sector of a given Laue class. We show this by comparing the vectors we get by: 1. Sampling rotations for *4/mmm* and then rotating :math:`\mathbf{v_z}` 2. Sampling all of *S2* but only keeping those within the corresponding fundamental sector. Apart from the first rotation, all rotations have a Euler angle :math:`\phi = 0^{\circ}`. These "reduced" rotations can be useful in template matching of spot patterns from the transmission electron microscope. .. GENERATED FROM PYTHON SOURCE LINES 21-36 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from orix import plot, sampling from orix.quaternion import symmetry from orix.vector import Vector3d # Sample rotations with an average misorientation res = 2 pg = symmetry.D4h # 4/mmm R = sampling.get_sample_reduced_fundamental(res, point_group=pg) print(np.allclose(R.to_euler()[1:, 0], 0)) .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 37-38 Get vectors within the fundamental sector following the two routes .. GENERATED FROM PYTHON SOURCE LINES 38-48 .. code-block:: Python v1 = R * Vector3d.zvector() v2 = sampling.sample_S2(res) v2 = v2[v2 <= pg.fundamental_sector] # Only equivalent for the same S2 sampling method print(np.allclose(v1.data, v2.data)) print(v1) print(v2) .. rst-class:: sphx-glr-script-out .. code-block:: none True Vector3d (852,) [[0. 0. 1. ] [0.0341 0. 0.9994] [0.0682 0. 0.9977] ... [0.7063 0.7063 0.0483] [0.7069 0.7069 0.0241] [0.7071 0.7071 0. ]] Vector3d (852,) [[ 0. 0. 1. ] [ 0.0341 0. 0.9994] [ 0.0682 0. 0.9977] ... [ 0.7063 0.7063 0.0483] [ 0.7069 0.7069 0.0241] [ 0.7071 0.7071 -0. ]] .. GENERATED FROM PYTHON SOURCE LINES 49-50 Plot the vectors in the fundamental sector of Laue group 4/mmm .. GENERATED FROM PYTHON SOURCE LINES 50-58 .. code-block:: Python fig, (ax0, ax1) = plt.subplots( ncols=2, subplot_kw={"projection": "ipf", "symmetry": pg}, layout="tight" ) ax0.scatter(v1, s=5) ax1.scatter(v2, c="C1", s=5) ax0.set_title("Rotated Z vectors", loc="left") ax1.set_title("Directly sampled", loc="left") _ = fig.suptitle("Vectors in the fundamental sector of 4/mmm", y=0.8) .. image-sg:: /examples/rotations/images/sphx_glr_rotations_mapping_fundamental_sector_001.png :alt: Vectors in the fundamental sector of 4/mmm, Rotated Z vectors, Directly sampled :srcset: /examples/rotations/images/sphx_glr_rotations_mapping_fundamental_sector_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.733 seconds) **Estimated memory usage:** 353 MB .. _sphx_glr_download_examples_rotations_rotations_mapping_fundamental_sector.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: rotations_mapping_fundamental_sector.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: rotations_mapping_fundamental_sector.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: rotations_mapping_fundamental_sector.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_