{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The implementation is based on the mathematical formula provided in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and the first known presentation of this algorithm, derived from study of 4-D geometry, is credited to Glenn Davis in a footnote of the original quaternion Slerp publication by Ken Shoemake "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 1.5.0"
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "",
              "annotation": "ValueError",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "start"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " or "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "end"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are not on the unit n-sphere, or for a variety of degenerate conditions."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "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": "result",
              "annotation": "(t.size, D)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array of doubles containing the interpolated spherical path and including start and end when 0 and 1 t are used. The interpolated values should correspond to the same sort order provided in the t array. The result may be 1-dimensional if "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "t"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is a float."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Geometric spherical linear interpolation."
            }
          ]
        }
      ],
      "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": "start",
              "annotation": "(n_dimensions, ) array-like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Single n-dimensional input coordinate in a 1-D array-like object. "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "n",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must be greater than 1."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "end",
              "annotation": "(n_dimensions, ) array-like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Single n-dimensional input coordinate in a 1-D array-like object. "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "n",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must be greater than 1."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "t",
              "annotation": "float or (n_points,) 1D array-like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "A float or 1D array-like of doubles representing interpolation parameters. A common approach is to generate the array with "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "np.linspace(0, 1, n_pts)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for linearly spaced points. Ascending, descending, and scrambled orders are permitted."
                    }
                  ]
                },
                {
                  "__type": "Admonition",
                  "__tag": 4056,
                  "kind": "versionchanged",
                  "base_type": "neutral",
                  "children": [
                    {
                      "__type": "AdmonitionTitle",
                      "__tag": 4055,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "versionchanged 1.17.0"
                        }
                      ]
                    },
                    {
                      "__type": "Paragraph",
                      "__tag": 4045,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "Extrapolation is permitted, allowing values below "
                        },
                        {
                          "__type": "InlineRole",
                          "__tag": 4003,
                          "value": "0",
                          "domain": null,
                          "role": null,
                          "inventory": null
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": " and above "
                        },
                        {
                          "__type": "InlineRole",
                          "__tag": 4003,
                          "value": "1",
                          "domain": null,
                          "role": null,
                          "inventory": null
                        },
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "tol",
              "annotation": "float",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The absolute tolerance for determining if the start and end coordinates are antipodes."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The interpolation occurs along a unit-radius great circle arc in arbitrary dimensional space."
            }
          ]
        }
      ],
      "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/_geometric_slerp.py",
  "item_line": 33,
  "item_type": "function",
  "aliases": [
    "scipy.spatial.geometric_slerp"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Interpolate four linearly-spaced values on the circumference of\na circle spanning 90 degrees:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.spatial import geometric_slerp\nimport matplotlib.pyplot as plt\nfig = plt.figure()\nax = fig.add_subplot(111)\nstart = np.array([1, 0])\nend = np.array([0, 1])\nt_vals = np.linspace(0, 1, 4)\nresult = geometric_slerp(start,\n                         end,\n                         t_vals)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe interpolated results should be at 30 degree intervals\nrecognizable on the unit circle:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.scatter(result[...,0], result[...,1], c='k')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "circle = plt.Circle((0, 0), 1, color='grey')\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.add_artist(circle)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.set_aspect('equal')\nplt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-bb8878fe8231df10.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAttempting to interpolate between antipodes on a circle is\nambiguous because there are two possible paths, and on a\nsphere there are infinite possible paths on the geodesic surface.\nNonetheless, one of the ambiguous paths is returned along\nwith a warning:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import warnings\nopposite_pole = np.array([-1, 0])\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "with warnings.catch_warnings():\n    warnings.simplefilter(\"ignore\", UserWarning)\n    geometric_slerp(start,\n                    opposite_pole,\n                    t_vals)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nExtend the original example to a sphere and plot interpolation\npoints in 3D:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from mpl_toolkits.mplot3d import proj3d\nfig = plt.figure()\nax = fig.add_subplot(111, projection='3d')\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nPlot the unit sphere for reference (optional):\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "u = np.linspace(0, 2 * np.pi, 100)\nv = np.linspace(0, np.pi, 100)\nx = np.outer(np.cos(u), np.sin(v))\ny = np.outer(np.sin(u), np.sin(v))\nz = np.outer(np.ones(np.size(u)), np.cos(v))\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.plot_surface(x, y, z, color='y', alpha=0.1)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nInterpolating over a larger number of points\nmay provide the appearance of a smooth curve on\nthe surface of the sphere, which is also useful\nfor discretized integration calculations on a\nsphere surface:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "start = np.array([1, 0, 0])\nend = np.array([0, 0, 1])\nt_vals = np.linspace(0, 1, 200)\nresult = geometric_slerp(start,\n                         end,\n                         t_vals)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.plot(result[...,0],\n        result[...,1],\n        result[...,2],\n        c='k')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-629bd5fc1e3697da.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIt is also possible to perform extrapolations outside\nthe interpolation interval by using interpolation parameter\nvalues below 0 or above 1. For example, the above example\nmay be adjusted to extrapolate to an antipodal position:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "fig = plt.figure()\nax = fig.add_subplot(111, projection='3d')\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.plot_surface(x, y, z, color='y', alpha=0.1)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "start = np.array([1, 0, 0])\nend = np.array([0, 0, 1])\nt_vals = np.linspace(0, 2, 400)\nresult = geometric_slerp(start,\n                         end,\n                         t_vals)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.plot(result[...,0], result[...,1], result[...,2], c='k')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success"
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "1.17.1",
          "kind": "assets",
          "path": "fig-588288dfae26969e.png"
        }
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "scipy.spatial.transform.Slerp",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.spatial.transform._rotation:Slerp"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "3-D Slerp that works with quaternions"
            }
          ]
        }
      ],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "start",
        "annotation": "npt.ArrayLike",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "end",
        "annotation": "npt.ArrayLike",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "t",
        "annotation": "npt.ArrayLike",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "tol",
        "annotation": "float",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "1e-07"
      }
    ],
    "return_annotation": "np.ndarray",
    "target_name": "geometric_slerp"
  },
  "references": [
    ".. [1] https://en.wikipedia.org/wiki/Slerp#Geometric_Slerp",
    ".. [2] Ken Shoemake (1985) Animating rotation with quaternion curves.",
    "       ACM SIGGRAPH Computer Graphics, 19(3): 245-254."
  ],
  "qa": "scipy.spatial._geometric_slerp:geometric_slerp",
  "arbitrary": [],
  "local_refs": [
    "end",
    "result",
    "start",
    "t",
    "tol"
  ]
}