{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "a69096ad",
            "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": "af15b86e",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.spatial.transform import Rotation as R\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "dfa8d5d1",
            "cell_type": "markdown",
            "source": "Represent a single rotation:\n",
            "metadata": {}
        },
        {
            "id": "98e4bba2",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_rotvec([0, 0, np.pi/2])\nr.as_matrix()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],\n       [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],\n       [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "ef1e2b3f",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_matrix().shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(3, 3)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "84697c35",
            "cell_type": "markdown",
            "source": "Represent a stack with a single rotation:\n",
            "metadata": {}
        },
        {
            "id": "677fb111",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_quat([[1, 1, 0, 0]])\nr.as_matrix()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[[ 0.,  1.,  0.],\n        [ 1.,  0.,  0.],\n        [ 0.,  0., -1.]]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4a6b204f",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_matrix().shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(1, 3, 3)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "6cd8e7cb",
            "cell_type": "markdown",
            "source": "Represent multiple rotations:\n",
            "metadata": {}
        },
        {
            "id": "158824a8",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_rotvec([[np.pi/2, 0, 0], [0, 0, np.pi/2]])\nr.as_matrix()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[[ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],\n        [ 0.00000000e+00,  2.22044605e-16, -1.00000000e+00],\n        [ 0.00000000e+00,  1.00000000e+00,  2.22044605e-16]],\n       [[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],\n        [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],\n        [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "a94d2903",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r.as_matrix().shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(2, 3, 3)"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}