{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "5f5bdd4a",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "a39c5a4d",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.spatial.transform import Rotation as R\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "175f26d6",
            "cell_type": "markdown",
            "source": "Davenport angles are a generalization of Euler angles, when we use the\ncanonical basis axes:\n",
            "metadata": {}
        },
        {
            "id": "617c0897",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "ex = [1, 0, 0]\ney = [0, 1, 0]\nez = [0, 0, 1]",
            "outputs": []
        },
        {
            "id": "77546a62",
            "cell_type": "markdown",
            "source": "Represent a single rotation:\n",
            "metadata": {}
        },
        {
            "id": "b51844e6",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_rotvec([0, 0, np.pi/2])\nr.as_davenport([ez, ex, ey], 'extrinsic', degrees=True)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([90.,  0.,  0.])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "c197d938",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_euler('zxy', degrees=True)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([90.,  0.,  0.])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "12abab5a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True).shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(3,)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "c9b47147",
            "cell_type": "markdown",
            "source": "Represent a stack of single rotation:\n",
            "metadata": {}
        },
        {
            "id": "2cb90e39",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_rotvec([[0, 0, np.pi/2]])\nr.as_davenport([ez, ex, ey], 'extrinsic', degrees=True)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[90.,  0.,  0.]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "44bb233c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True).shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(1, 3)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "ea298bc4",
            "cell_type": "markdown",
            "source": "Represent multiple rotations in a single object:\n",
            "metadata": {}
        },
        {
            "id": "f180db9b",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_rotvec([\n[0, 0, 90],\n[45, 0, 0]], degrees=True)\nr.as_davenport([ez, ex, ey], 'extrinsic', degrees=True)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[90.,  0.,  0.],\n       [ 0., 45.,  0.]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "6b31e501",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_davenport([ez, ex, ey], 'extrinsic', degrees=True).shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(2, 3)"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}