class_docstr: Interpolate rotations with continuous angular rate and acceleration.
  
  The rotation vectors between each consecutive orientation are cubic
  functions of time and it is guaranteed that angular rate and acceleration
  are continuous. Such interpolation are analogous to cubic spline
  interpolation.
  
  Refer to [1]_ for math and implementation details.
  
  Parameters
  ----------
  times : array_like, shape (N,)
      Times of the known rotations. At least 2 times must be specified.
  rotations : `Rotation` instance
      Rotations to perform the interpolation between. Must contain N
      rotations.
  
  Methods
  -------
  __call__
  
  References
  ----------
  .. [1] `Smooth Attitude Interpolation
          <https://github.com/scipy/scipy/files/2932755/attitude_interpolation.pdf>`_
  
  Examples
  --------
  >>> from scipy.spatial.transform import Rotation, RotationSpline
  
  Define the sequence of times and rotations from the Euler angles:
  
  >>> times = [0, 10, 20, 40]
  >>> angles = [[-10, 20, 30], [0, 15, 40], [-30, 45, 30], [20, 45, 90]]
  >>> rotations = Rotation.from_euler('XYZ', angles, degrees=True)
  
  Create the interpolator object:
  
  >>> spline = RotationSpline(times, rotations)
  
  Interpolate the Euler angles, angular rate and acceleration:
  
  >>> angular_rate = np.rad2deg(spline(times, 1))
  >>> angular_acceleration = np.rad2deg(spline(times, 2))
  >>> times_plot = np.linspace(times[0], times[-1], 100)
  >>> angles_plot = spline(times_plot).as_euler('XYZ', degrees=True)
  >>> angular_rate_plot = np.rad2deg(spline(times_plot, 1))
  >>> angular_acceleration_plot = np.rad2deg(spline(times_plot, 2))
  
  On this plot you see that Euler angles are continuous and smooth:
  
  >>> import matplotlib.pyplot as plt
  >>> plt.plot(times_plot, angles_plot)
  >>> plt.plot(times, angles, 'x')
  >>> plt.title("Euler angles")
  >>> plt.show()
  
  The angular rate is also smooth:
  
  >>> plt.plot(times_plot, angular_rate_plot)
  >>> plt.plot(times, angular_rate, 'x')
  >>> plt.title("Angular rate")
  >>> plt.show()
  
  The angular acceleration is continuous, but not smooth. Also note that
  the angular acceleration is not a piecewise-linear function, because
  it is different from the second derivative of the rotation vector (which
  is a piecewise-linear function as in the cubic spline).
  
  >>> plt.plot(times_plot, angular_acceleration_plot)
  >>> plt.plot(times, angular_acceleration, 'x')
  >>> plt.title("Angular acceleration")
  >>> plt.show()
class_docstr_tok: ["Interpolate","rotations","with","continuous","angular","rate","and","acceleration",".","The","rotation","vectors","between","each","consecutive","orientation","are","cubic","functions","of","time","and","it","is","guaranteed","that","angular","rate","and","acceleration","are","continuous",".","Such","interpolation","are","analogous","to","cubic","spline","interpolation",".","Refer","to","[","1","]","_","for","math","and","implementation","details",".","Parameters","--","--","--","--","--","times",":","array_like",",","shape","(","N",",",")","Times","of","the","known","rotations",".","At","least","2","times","must","be","specified",".","rotations",":","`","Rotation","`","instance","Rotations","to","perform","the","interpolation","between",".","Must","contain","N","rotations",".","Methods","--","--","--","-","__call__","References","--","--","--","--","--","..","[","1","]","`","Smooth","Attitude","Interpolation","<","https",":","\/\/github.com\/scipy\/scipy\/files\/2932755\/attitude_interpolation.pdf",">","`","_","Examples","--","--","--","--",">",">",">","from","scipy.spatial.transform","import","Rotation",",","RotationSpline","Define","the","sequence","of","times","and","rotations","from","the","Euler","angles",":",">",">",">","times","=","[","0",",","10",",","20",",","40","]",">",">",">","angles","=","[","[","-10",",","20",",","30","]",",","[","0",",","15",",","40","]",",","[","-30",",","45",",","30","]",",","[","20",",","45",",","90","]","]",">",">",">","rotations","=","Rotation.from_euler","(","'XYZ","'",",","angles",",","degrees=True",")","Create","the","interpolator","object",":",">",">",">","spline","=","RotationSpline","(","times",",","rotations",")","Interpolate","the","Euler","angles",",","angular","rate","and","acceleration",":",">",">",">","angular_rate","=","np.rad2deg","(","spline","(","times",",","1",")",")",">",">",">","angular_acceleration","=","np.rad2deg","(","spline","(","times",",","2",")",")",">",">",">","times_plot","=","np.linspace","(","times","[","0","]",",","times","[","-1","]",",","100",")",">",">",">","angles_plot","=","spline","(","times_plot",")",".as_euler","(","'XYZ","'",",","degrees=True",")",">",">",">","angular_rate_plot","=","np.rad2deg","(","spline","(","times_plot",",","1",")",")",">",">",">","angular_acceleration_plot","=","np.rad2deg","(","spline","(","times_plot",",","2",")",")","On","this","plot","you","see","that","Euler","angles","are","continuous","and","smooth",":",">",">",">","import","matplotlib.pyplot","as","plt",">",">",">","plt.plot","(","times_plot",",","angles_plot",")",">",">",">","plt.plot","(","times",",","angles",",","'","x","'",")",">",">",">","plt.title","(","``","Euler","angles","''",")",">",">",">","plt.show","(",")","The","angular","rate","is","also","smooth",":",">",">",">","plt.plot","(","times_plot",",","angular_rate_plot",")",">",">",">","plt.plot","(","times",",","angular_rate",",","'","x","'",")",">",">",">","plt.title","(","``","Angular","rate","''",")",">",">",">","plt.show","(",")","The","angular","acceleration","is","continuous",",","but","not","smooth",".","Also","note","that","the","angular","acceleration","is","not","a","piecewise-linear","function",",","because","it","is","different","from","the","second","derivative","of","the","rotation","vector","(","which","is","a","piecewise-linear","function","as","in","the","cubic","spline",")",".",">",">",">","plt.plot","(","times_plot",",","angular_acceleration_plot",")",">",">",">","plt.plot","(","times",",","angular_acceleration",",","'","x","'",")",">",">",">","plt.title","(","``","Angular","acceleration","''",")",">",">",">","plt.show","(",")"]
code: def __init__(self, times, rotations):
      from scipy.interpolate import PPoly
  
      if rotations.single:
          raise ValueError(
              "`rotations` must be a sequence of rotations."
          )
  
      if len(rotations) == 1:
          raise ValueError(
              "`rotations` must contain at least 2 rotations."
          )
  
      times = np.asarray(times, dtype=float)
      if times.ndim != 1:
          raise ValueError("`times` must be 1-dimensional.")
  
      if len(times) != len(rotations):
          raise ValueError(
              "Expected number of rotations to be equal to "
              "number of timestamps given, got {} rotations "
              "and {} timestamps.".format(len(rotations), len(times))
          )
  
      dt = np.diff(times)
      if np.any(dt <= 0):
          raise ValueError(
              "Values in `times` must be in a strictly "
              "increasing order."
          )
  
      rotvecs = (rotations[:-1].inv() * rotations[1:]).as_rotvec()
      angular_rates = rotvecs / dt[:, None]
  
      if len(rotations) == 2:
          rotvecs_dot = angular_rates
      else:
          angular_rates, rotvecs_dot = self._solve_for_angular_rates(
              dt, angular_rates, rotvecs
          )
  
      dt = dt[:, None]
      coeff = np.empty((4, len(times) - 1, 3))
      coeff[0] = (
          -2 * rotvecs + dt * angular_rates + dt * rotvecs_dot
      ) / dt**3
      coeff[1] = (
          3 * rotvecs - 2 * dt * angular_rates - dt * rotvecs_dot
      ) / dt**2
      coeff[2] = angular_rates
      coeff[3] = 0
  
      self.times = times
      self.rotations = rotations
      self.interpolator = PPoly(coeff, times)
  
file_path: catboost/contrib/python/scipy/py3/scipy/spatial/transform/_rotation_spline.py
imports: import numpy
  from scipy.linalg import solve_banded
  from .rotation import Rotation
label_desc: Use image node_id 2 to create a new RotationSpline object  with example: obj = RotationSpline(times, rotations)