{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "b6351701",
            "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": "461ef94f",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.spatial.transform import RigidTransform as Tf\nfrom scipy.spatial.transform import Rotation as R\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "3cbfbafa",
            "cell_type": "markdown",
            "source": "Creating a transform from a single rotation:\n",
            "metadata": {}
        },
        {
            "id": "ef5bb818",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_euler(\"ZYX\", [90, 30, 0], degrees=True)\nr.apply([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([0.       , 0.8660254, -0.5     ])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "3d0a4b3c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf = Tf.from_rotation(r)\ntf.apply([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([0.       , 0.8660254, -0.5     ])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "2434133b",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf.single",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "0f84b827",
            "cell_type": "markdown",
            "source": "The upper 3x3 submatrix of the transformation matrix is the rotation\nmatrix:\n",
            "metadata": {}
        },
        {
            "id": "eb47d006",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "np.allclose(tf.as_matrix()[:3, :3], r.as_matrix(), atol=1e-12)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "1d1161d7",
            "cell_type": "markdown",
            "source": "Creating multiple transforms from a stack of rotations:\n",
            "metadata": {}
        },
        {
            "id": "42ea6a20",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "r = R.from_euler(\"ZYX\", [[90, 30, 0], [45, 30, 60]], degrees=True)\nr.apply([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[0.        , 0.8660254 , -0.5       ],\n       [0.61237244, 0.61237244, -0.5       ]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4c3c186d",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf = Tf.from_rotation(r)\ntf.apply([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[0.        , 0.8660254 , -0.5       ],\n       [0.61237244, 0.61237244, -0.5       ]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "ca435529",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf.single",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "False"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "75f87a59",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "len(tf)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "2"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}