{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "1ab16523",
            "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": "0222b016",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.spatial.transform import RigidTransform as Tf\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "a899dcdb",
            "cell_type": "markdown",
            "source": "Creating a transform from a single translation vector:\n",
            "metadata": {}
        },
        {
            "id": "62352fa3",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "t = np.array([2, 3, 4])\nt + np.array([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([3, 3, 4])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "49feff05",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf = Tf.from_translation(t)\ntf.apply([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([3., 3., 4.])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "7d356eb7",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf.single",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "fb8d2e52",
            "cell_type": "markdown",
            "source": "The top 3x1 points in the rightmost column of the transformation matrix\nis the translation vector:\n",
            "metadata": {}
        },
        {
            "id": "32d544c8",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf.as_matrix()",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[1., 0., 0., 2.],\n       [0., 1., 0., 3.],\n       [0., 0., 1., 4.],\n       [0., 0., 0., 1.]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "824304a2",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "np.allclose(tf.as_matrix()[:3, 3], t)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "8848c33d",
            "cell_type": "markdown",
            "source": "Creating multiple transforms from a stack of translation vectors:\n",
            "metadata": {}
        },
        {
            "id": "621b0fbb",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "t = np.array([[2, 3, 4], [1, 0, 0]])\nt + np.array([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[3, 3, 4],\n       [2, 0, 0]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4b6ec53c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf = Tf.from_translation(t)\ntf.apply([1, 0, 0])",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[3., 3., 4.],\n       [2., 0., 0.]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "3a08ad61",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "np.allclose(tf.as_matrix()[:, :3, 3], t)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "8fa2442a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "tf.single",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "False"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "623f8cce",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "len(tf)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "2"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}