{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "transformed_vector",
              "annotation": "numpy.ndarray, shape (..., 3)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The transformed vector(s) with shape determined by broadcasting the transform and vector shapes together."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Apply the transform to a vector."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "vector",
              "annotation": "array_like, shape (..., 3)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Vector(s) to be transformed. Each vector[..., :] represents a 3D vector."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "inverse",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If True, the inverse of the transform is applied to the vector."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If the original frame transforms to the final frame by this transform, then its application to a vector can be seen in two ways:"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "BulletList",
              "__tag": 4053,
              "ordered": false,
              "start": 1,
              "children": [
                {
                  "__type": "ListItem",
                  "__tag": 4054,
                  "children": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "As a projection of vector components expressed in the final frame       to the original frame."
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "ListItem",
                  "__tag": 4054,
                  "children": [
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "As the physical transformation of a vector being glued to the       original frame as it transforms. In this case the vector       components are expressed in the original frame before and after       the transformation."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In terms of the rotation matrix and translation, this application is the same as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "self.translation + (mat @ vector[..., np.newaxis])[..., 0]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", where "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "mat = self.rotation.as_matrix()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For a single transform, this is the same as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "self.translation + vector @ self.rotation.as_matrix().T"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/spatial/transform/_rigid_transform.py",
  "item_line": 1743,
  "item_type": "function",
  "aliases": [
    "scipy.spatial.transform.RigidTransform.apply"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.spatial.transform import RigidTransform as Tf\nfrom scipy.spatial.transform import Rotation as R\nimport numpy as np\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nApply a single transform to a vector. Here the transform is just a\ntranslation, so the result is the vector added to the translation\nvector.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "t = np.array([1, 2, 3])\ntf = Tf.from_translation(t)\nt + np.array([1, 0, 0])\ntf.apply([1, 0, 0])\n",
        "execution_status": "success",
        "out": "array([2., 2., 3.])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nApply a single transform to a stack of vectors:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "tf.apply([[1, 0, 0], [0, 1, 0]])\n",
        "execution_status": "success",
        "out": "array([[2., 2., 3.],\n       [1., 3., 3.]])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nApply the inverse of a transform to a vector, so the result is the\nnegative of the translation vector added to the vector.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "-t + np.array([1, 0, 0])\ntf.apply([1, 0, 0], inverse=True)\n",
        "execution_status": "failure",
        "out": "array([ 0., -2., -3.])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBroadcasting is supported when applying multiple transforms to an N-dimensional\narray of vectors.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "tf = Tf.from_translation(np.ones((4, 5, 1, 3)))\nvectors = np.zeros((2, 3))\ntf.apply(vectors).shape\n",
        "execution_status": "success",
        "out": "(4, 5, 2, 3)\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nFor transforms which are not just pure translations, applying it to a\nvector is the same as applying the rotation component to the vector and\nthen adding the translation component.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r = R.from_euler('z', 60, degrees=True)\ntf = Tf.from_components(t, r)\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "t + r.apply([1, 0, 0])\ntf.apply([1, 0, 0])\n",
        "execution_status": "failure",
        "out": "array([1.5    , 2.86603, 3.     ])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWhen applying the inverse of a transform, the result is the negative of\nthe translation vector added to the vector, and then rotated by the\ninverse rotation.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r.inv().apply(-t + np.array([1, 0, 0]))\ntf.apply([1, 0, 0], inverse=True)\n",
        "execution_status": "failure",
        "out": "array([-1.73205, -1.     , -3.     ])\n"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "self",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "vector",
        "annotation": "ArrayLike",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "inverse",
        "annotation": "bool",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      }
    ],
    "return_annotation": "Array",
    "target_name": "apply"
  },
  "references": null,
  "qa": "scipy.spatial.transform._rigid_transform:RigidTransform.apply",
  "arbitrary": [],
  "local_refs": [
    "inverse",
    "transformed_vector",
    "vector"
  ]
}