{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Rotations {#rotate_example}\n\nRotations of a mesh about its axes. In this model, the x axis is from\nthe left to right; the y axis is from bottom to top; and the z axis\nemerges from the image. The camera location is the same in all four\nimages.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import pyvista as pv\nfrom pyvista import examples"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Define camera and axes\n\nDefine camera and axes. Setting axes origin to `(3.0, 3.0, 3.0)`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = examples.download_cow()\nmesh.points /= 1.5  # scale the mesh\n\ncamera = pv.Camera()\ncamera.position = (30.0, 30.0, 30.0)\ncamera.focal_point = (5.0, 5.0, 5.0)\n\naxes = pv.Axes(show_actor=True, actor_scale=2.0, line_width=5)\naxes.origin = (3.0, 3.0, 3.0)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Original Mesh\n\nPlot original mesh. Add axes actor to Plotter.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = pv.Plotter()\n\np.add_text(\"Mesh\", font_size=24)\np.add_actor(axes.actor)\np.camera = camera\np.add_mesh(mesh)\n\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Rotation about the x axis\n\nPlot the mesh rotated about the x axis every 60 degrees. Add the axes\nactor to the Plotter and set the axes origin to the point of rotation.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = pv.Plotter()\n\np.add_text(\"X-Axis Rotation\", font_size=24)\np.add_actor(axes.actor)\np.camera = camera\n\nfor i in range(6):\n    rot = mesh.rotate_x(60 * i, point=axes.origin, inplace=False)\n    p.add_mesh(rot)\n\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Rotation about the y axis\n\nPlot the mesh rotated about the y axis every 60 degrees. Add the axes\nactor to the Plotter and set the axes origin to the point of rotation.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = pv.Plotter()\n\np.add_text(\"Y-Axis Rotation\", font_size=24)\np.camera = camera\np.add_actor(axes.actor)\n\nfor i in range(6):\n    rot = mesh.rotate_y(60 * i, point=axes.origin, inplace=False)\n    p.add_mesh(rot)\n\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Rotation about the z axis\n\nPlot the mesh rotated about the z axis every 60 degrees. Add axes actor\nto the Plotter and set the axes origin to the point of rotation.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = pv.Plotter()\n\np.add_text(\"Z-Axis Rotation\", font_size=24)\np.camera = camera\np.add_actor(axes.actor)\n\nfor i in range(6):\n    rot = mesh.rotate_z(60 * i, point=axes.origin, inplace=False)\n    p.add_mesh(rot)\n\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Rotation about a custom vector\n\nPlot the mesh rotated about a custom vector every 60 degrees. Add the\naxes actor to the Plotter and set axes origin to the point of rotation.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = pv.Plotter()\n\np.add_text(\"Custom Vector Rotation\", font_size=24)\np.camera = camera\np.add_actor(axes.actor)\nfor i in range(6):\n    rot = mesh.copy()\n    rot.rotate_vector(vector=(1, 1, 1), angle=60 * i, point=axes.origin)\n    p.add_mesh(rot)\n\np.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}