{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "from_quat",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.spatial.transform._rotation:Rotation.from_quat"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ✅                   \nPyTorch               ✅                     ✅                   \nJAX                   ✅                     ✅                   \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dev-arrayapi",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "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": "rotation",
              "annotation": "`Rotation` instance",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Object containing the rotations represented by input quaternions."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Initialize from quaternions."
            }
          ]
        }
      ],
      "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": "quat",
              "annotation": "array_like, shape (..., 4)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Each row is a (possibly non-unit norm) quaternion representing an active rotation. Each quaternion will be normalized to unit norm."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "scalar_first",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Whether the scalar component goes first or last. Default is False, i.e. the scalar-last order is assumed."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Rotations in 3 dimensions can be represented using unit norm quaternions "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The 4 components of a quaternion are divided into a scalar part "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "w"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and a vector part "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "(x, y, z)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and can be expressed from the angle "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "theta"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and the axis "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "n"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of a rotation as follows      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "w = cos(theta / 2)\nx = sin(theta / 2) * n_x\ny = sin(theta / 2) * n_y\nz = sin(theta / 2) * n_z",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "There are 2 conventions to order the components in a quaternion:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "scalar-first order -- "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(w, x, y, z)"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "scalar-last order -- "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "(x, y, z, w)"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The choice is controlled by "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "scalar_first"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " argument. By default, it is False and the scalar-last order is assumed."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Advanced users may be interested in the \"double cover\" of 3D space by the quaternion representation "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". As of version 1.11.0, the following subset (and only this subset) of operations on a "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "Rotation",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.spatial.transform._rotation:Rotation"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " corresponding to a quaternion "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "q"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are guaranteed to preserve the double cover property: "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r = Rotation.from_quat(q)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r.as_quat(canonical=False)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r.inv()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and composition using the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "*"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " operator such as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "r*r"
            },
            {
              "__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/_rotation.py",
  "item_line": 374,
  "item_type": "staticmethod",
  "aliases": [
    "scipy.spatial.transform.Rotation.from_quat"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.spatial.transform import Rotation as R\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nA rotation can be initialized from a quaternion with the scalar-last\n(default) or scalar-first component order as shown below:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r = R.from_quat([0, 0, 0, 1])\nr.as_matrix()\nr = R.from_quat([1, 0, 0, 0], scalar_first=True)\nr.as_matrix()\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIt is possible to initialize multiple rotations in a single object by\npassing an N-dimensional array:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r = R.from_quat([[\n[1, 0, 0, 0],\n[0, 0, 0, 1]\n]])\nr.as_quat()\nr.as_quat().shape\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIt is also possible to have a stack of a single rotation:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r = R.from_quat([[0, 0, 0, 1]])\nr.as_quat()\nr.as_quat().shape\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nQuaternions are normalized before initialization.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r = R.from_quat([0, 0, 1, 1])\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "r.as_quat()\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "quat",
        "annotation": "ArrayLike",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "scalar_first",
        "annotation": "bool",
        "kind": "KEYWORD_ONLY",
        "default": "False"
      }
    ],
    "return_annotation": "Rotation",
    "target_name": "from_quat"
  },
  "references": [
    ".. [1] https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation",
    ".. [2] Hanson, Andrew J. \"Visualizing quaternions.\"",
    "    Morgan Kaufmann Publishers Inc., San Francisco, CA. 2006."
  ],
  "qa": "scipy.spatial.transform._rotation:Rotation.from_quat",
  "arbitrary": [],
  "local_refs": [
    "quat",
    "rotation",
    "scalar_first"
  ]
}