{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "73dac52b",
            "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": "c07b7104",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.spatial.transform import RigidTransform as Tf\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "4e7c66b6",
            "cell_type": "markdown",
            "source": "Creating from a single 6d vector of exponential coordinates:\n",
            "metadata": {}
        },
        {
            "id": "37abfcac",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf = Tf.from_exp_coords([\n    -2.01041204, -0.52983629, 0.65773501,\n    0.10386614, 0.05855009, 0.54959179])\ntf.as_matrix()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[0.76406621, 0.10504613, -0.63652819, -0.10209961],\n       [0.59956454, -0.47987325, 0.64050295, 0.40158789],\n       [-0.2381705, -0.87102639, -0.42963687, 0.19637636],\n       [0., 0., 0., 1.]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "30ada1d4",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf.single",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "0c1335ac",
            "cell_type": "markdown",
            "source": "A vector of zeros represents the identity transform:\n",
            "metadata": {}
        },
        {
            "id": "a701c3e7",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf = Tf.from_exp_coords(np.zeros(6))\ntf.as_matrix()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[1., 0., 0., 0.],\n       [0., 1., 0., 0.],\n       [0., 0., 1., 0.],\n       [0., 0., 0., 1.]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "54ce9524",
            "cell_type": "markdown",
            "source": "The last three numbers encode translation. If the first three numbers\nare zero, the last three components can be interpreted as the\ntranslation:\n",
            "metadata": {}
        },
        {
            "id": "4e3bce32",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf_trans = Tf.from_exp_coords([0, 0, 0, 4.3, -2, 3.4])\ntf_trans.translation",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([4.3, -2., 3.4])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "8cf4e4d1",
            "cell_type": "markdown",
            "source": "The first three numbers encode rotation as a rotation vector:\n",
            "metadata": {}
        },
        {
            "id": "0c6e857b",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf_rot = Tf.from_exp_coords([0.5, 0.3, 0.1, 0, 0, 0])\ntf_rot.rotation.as_rotvec()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([0.5, 0.3, 0.1])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "90ff1376",
            "cell_type": "markdown",
            "source": "Combining translation and rotation preserves the rotation vector,\nbut changes the last three components as they encode translation and\nrotation:\n",
            "metadata": {}
        },
        {
            "id": "fd817779",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "(tf_trans * tf_rot).as_exp_coords()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([0.5, 0.3, 0.1, 3.64305882, -1.25879559, 4.46109265])"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}