.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_rotated_geometry.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_auto_examples_02_rotated_geometry.py: Rotated Geometry ================ Rotation of a block model geometry is a common operation in geoscience applications. By rotating the geometry, we can align it with geological features. Rotation is typically specified in degrees from the cardinal orthonormal axes (x, y, z). .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: default import pyvista as pv from parq_blockmodel import RegularGeometry from parq_blockmodel.utils import rotation_to_axis_orientation # sphinx_gallery_thumbnail_number = 2 .. GENERATED FROM PYTHON SOURCE LINES 18-21 Create a Rotated Geometry ------------------------- Create a geometry with 30 degrees azimuth. .. GENERATED FROM PYTHON SOURCE LINES 21-43 .. code-block:: default axis_u, axis_v, axis_w = rotation_to_axis_orientation(axis_azimuth=30, axis_dip=0, axis_plunge=0) geom = RegularGeometry(corner=(0.0, 0.0, 0.0), block_size=(1.0, 1.0, 1.0), shape=(2, 2, 2), axis_u=axis_u, axis_v=axis_v, axis_w=axis_w) # Create a PyVista plotter isometric_view = [(6, 5, 3), # camera position (1, 1, 1), # focal point (center of the grid) (0, 0, 1), # view up direction ] plotter = pv.Plotter() edges = geom.to_pyvista().extract_all_edges() plotter.add_mesh(edges, color="black", line_width=1) plotter.show_axes() plotter.camera_position = isometric_view plotter.show(title="Rotated Regular Geometry", window_size=(800, 600)) .. image-sg:: /auto_examples/images/sphx_glr_02_rotated_geometry_001.png :alt: 02 rotated geometry :srcset: /auto_examples/images/sphx_glr_02_rotated_geometry_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 44-46 Visualise in 2D Slice at z=0.5 to intersect the first layer of cells .. GENERATED FROM PYTHON SOURCE LINES 46-67 .. code-block:: default slice_2d = geom.to_pyvista().slice(normal='z', origin=(0, 0, 0.5)) edges_2d = slice_2d.extract_all_edges() points = edges_2d.points labels = [f"({x:.1f}, {y:.1f})" for x, y, _ in points] centroids_mesh = slice_2d.cell_centers() centroids = centroids_mesh.points labels_centroids_2d = [f"C({x:.1f}, {y:.1f})" for x, y, _ in centroids] plotter = pv.Plotter() plotter.add_mesh(edges_2d, color="black", show_edges=True) plotter.add_point_labels(points, labels, font_size=12, point_color="red", point_size=10) plotter.add_points(centroids, color="blue", point_size=15, render_points_as_spheres=True) plotter.add_point_labels(centroids, labels_centroids_2d, font_size=12, point_color="blue", point_size=0, # Hide label points always_visible=True, render_points_as_spheres=False) plotter.show_axes() plotter.view_xy() plotter.show(title="2D Slice with Corner and Centroid Coordinates", window_size=(600, 600)) .. image-sg:: /auto_examples/images/sphx_glr_02_rotated_geometry_002.png :alt: 02 rotated geometry :srcset: /auto_examples/images/sphx_glr_02_rotated_geometry_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.334 seconds) .. _sphx_glr_download_auto_examples_02_rotated_geometry.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02_rotated_geometry.py <02_rotated_geometry.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02_rotated_geometry.ipynb <02_rotated_geometry.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_