class_docstr: Rotation in 3 dimensions.
  
  This class provides an interface to initialize from and represent rotations
  with:
  
      - Quaternions
      - Direction Cosine Matrices
      - Rotation Vectors
      - Euler angles
  
  The following operations on rotations are supported:
  
      - Application on vectors
      - Rotation Composition
      - Rotation Inversion
      - Rotation Indexing
  
  Indexing within a rotation is supported since multiple rotation transforms
  can be stored within a single `Rotation` instance.
  
  To create `Rotation` objects use `from_...` classmethods, `__init__` is not
  supposed to be used directly.
  
  Methods
  -------
  __len__
  from_quat
  from_dcm
  from_rotvec
  from_euler
  as_quat
  as_dcm
  as_rotvec
  as_euler
  apply
  __mul__
  inv
  __getitem__
  random
  
  Examples
  --------
  >>> from scipy.spatial.transform import Rotation as R
  
  A `Rotation` instance can be initialized in any of the above formats and
  converted to any of the others. The underlying object is independent of the
  representation used for initialization.
  
  Consider a counter-clockwise rotation of 90 degrees about the z-axis. This
  corresponds to the following quaternion (in scalar-last format):
  
  >>> r = R.from_quat([0, 0, np.sin(np.pi/4), np.cos(np.pi/4)])
  
  The rotation can be expressed in any of the other formats:
  
  >>> r.as_dcm()
  array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
  [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
  [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
  >>> r.as_rotvec()
  array([0.        , 0.        , 1.57079633])
  >>> r.as_euler('zyx', degrees=True)
  array([90.,  0.,  0.])
  
  The same rotation can be initialized using a direction cosine matrix:
  
  >>> r = R.from_dcm(np.array([
  ... [0, -1, 0],
  ... [1, 0, 0],
  ... [0, 0, 1]]))
  
  Representation in other formats:
  
  >>> r.as_quat()
  array([0.        , 0.        , 0.70710678, 0.70710678])
  >>> r.as_rotvec()
  array([0.        , 0.        , 1.57079633])
  >>> r.as_euler('zyx', degrees=True)
  array([90.,  0.,  0.])
  
  The rotation vector corresponding to this rotation is given by:
  
  >>> r = R.from_rotvec(np.pi/2 * np.array([0, 0, 1]))
  
  Representation in other formats:
  
  >>> r.as_quat()
  array([0.        , 0.        , 0.70710678, 0.70710678])
  >>> r.as_dcm()
  array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
         [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
         [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
  >>> r.as_euler('zyx', degrees=True)
  array([90.,  0.,  0.])
  
  The `from_euler` function is quite flexible in the range of input formats
  it supports. Here we initialize a single rotation about a single axis:
  
  >>> r = R.from_euler('z', 90, degrees=True)
  
  Again, the object is representation independent and can be converted to any
  other format:
  
  >>> r.as_quat()
  array([0.        , 0.        , 0.70710678, 0.70710678])
  >>> r.as_dcm()
  array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
         [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
         [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
  >>> r.as_rotvec()
  array([0.        , 0.        , 1.57079633])
  
  It is also possible to initialize multiple rotations in a single instance
  using any of the `from_...` functions. Here we initialize a stack of 3
  rotations using the `from_euler` function:
  
  >>> r = R.from_euler('zyx', [
  ... [90, 0, 0],
  ... [0, 45, 0],
  ... [45, 60, 30]], degrees=True)
  
  The other representations also now return a stack of 3 rotations. For
  example:
  
  >>> r.as_quat()
  array([[0.        , 0.        , 0.70710678, 0.70710678],
         [0.        , 0.38268343, 0.        , 0.92387953],
         [0.39190384, 0.36042341, 0.43967974, 0.72331741]])
  
  Applying the above rotations onto a vector:
  
  >>> v = [1, 2, 3]
  >>> r.apply(v)
  array([[-2.        ,  1.        ,  3.        ],
         [ 2.82842712,  2.        ,  1.41421356],
         [ 2.24452282,  0.78093109,  2.89002836]])
  
  A `Rotation` instance can be indexed and sliced as if it were a single
  1D array or list:
  
  >>> r.as_quat()
  array([[0.        , 0.        , 0.70710678, 0.70710678],
         [0.        , 0.38268343, 0.        , 0.92387953],
         [0.39190384, 0.36042341, 0.43967974, 0.72331741]])
  >>> p = r[0]
  >>> p.as_dcm()
  array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
         [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
         [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
  >>> q = r[1:3]
  >>> q.as_quat()
  array([[0.        , 0.38268343, 0.        , 0.92387953],
         [0.39190384, 0.36042341, 0.43967974, 0.72331741]])
  
  Multiple rotations can be composed using the `*` operator:
  
  >>> r1 = R.from_euler('z', 90, degrees=True)
  >>> r2 = R.from_rotvec([np.pi/4, 0, 0])
  >>> v = [1, 2, 3]
  >>> r2.apply(r1.apply(v))
  array([-2.        , -1.41421356,  2.82842712])
  >>> r3 = r2 * r1 # Note the order
  >>> r3.apply(v)
  array([-2.        , -1.41421356,  2.82842712])
  
  Finally, it is also possible to invert rotations:
  
  >>> r1 = R.from_euler('z', [90, 45], degrees=True)
  >>> r2 = r1.inv()
  >>> r2.as_euler('zyx', degrees=True)
  array([[-90.,   0.,   0.],
         [-45.,   0.,   0.]])
  
  These examples serve as an overview into the `Rotation` class and highlight
  major functionalities. For more thorough examples of the range of input and
  output formats supported, consult the individual method's examples.
class_docstr_tok: ["Rotation","in","3","dimensions",".","This","class","provides","an","interface","to","initialize","from","and","represent","rotations","with",":","-","Quaternions","-","Direction","Cosine","Matrices","-","Rotation","Vectors","-","Euler","angles","The","following","operations","on","rotations","are","supported",":","-","Application","on","vectors","-","Rotation","Composition","-","Rotation","Inversion","-","Rotation","Indexing","Indexing","within","a","rotation","is","supported","since","multiple","rotation","transforms","can","be","stored","within","a","single","`","Rotation","`","instance",".","To","create","`","Rotation","`","objects","use","`","from_","...","`","classmethods",",","`","__init__","`","is","not","supposed","to","be","used","directly",".","Methods","--","--","--","-","__len__","from_quat","from_dcm","from_rotvec","from_euler","as_quat","as_dcm","as_rotvec","as_euler","apply","__mul__","inv","__getitem__","random","Examples","--","--","--","--",">",">",">","from","scipy.spatial.transform","import","Rotation","as","R","A","`","Rotation","`","instance","can","be","initialized","in","any","of","the","above","formats","and","converted","to","any","of","the","others",".","The","underlying","object","is","independent","of","the","representation","used","for","initialization",".","Consider","a","counter-clockwise","rotation","of","90","degrees","about","the","z-axis",".","This","corresponds","to","the","following","quaternion","(","in","scalar-last","format",")",":",">",">",">","r","=","R.from_quat","(","[","0",",","0",",","np.sin","(","np.pi\/4",")",",","np.cos","(","np.pi\/4",")","]",")","The","rotation","can","be","expressed","in","any","of","the","other","formats",":",">",">",">","r.as_dcm","(",")","array","(","[","[","2.22044605e-16",",","-1.00000000e+00",",","0.00000000e+00","]",",","[","1.00000000e+00",",","2.22044605e-16",",","0.00000000e+00","]",",","[","0.00000000e+00",",","0.00000000e+00",",","1.00000000e+00","]","]",")",">",">",">","r.as_rotvec","(",")","array","(","[","0.",",","0.",",","1.57079633","]",")",">",">",">","r.as_euler","(","'zyx","'",",","degrees=True",")","array","(","[","90.",",","0.",",","0",".","]",")","The","same","rotation","can","be","initialized","using","a","direction","cosine","matrix",":",">",">",">","r","=","R.from_dcm","(","np.array","(","[","...","[","0",",","-1",",","0","]",",","...","[","1",",","0",",","0","]",",","...","[","0",",","0",",","1","]","]",")",")","Representation","in","other","formats",":",">",">",">","r.as_quat","(",")","array","(","[","0.",",","0.",",","0.70710678",",","0.70710678","]",")",">",">",">","r.as_rotvec","(",")","array","(","[","0.",",","0.",",","1.57079633","]",")",">",">",">","r.as_euler","(","'zyx","'",",","degrees=True",")","array","(","[","90.",",","0.",",","0",".","]",")","The","rotation","vector","corresponding","to","this","rotation","is","given","by",":",">",">",">","r","=","R.from_rotvec","(","np.pi\/2","*","np.array","(","[","0",",","0",",","1","]",")",")","Representation","in","other","formats",":",">",">",">","r.as_quat","(",")","array","(","[","0.",",","0.",",","0.70710678",",","0.70710678","]",")",">",">",">","r.as_dcm","(",")","array","(","[","[","2.22044605e-16",",","-1.00000000e+00",",","0.00000000e+00","]",",","[","1.00000000e+00",",","2.22044605e-16",",","0.00000000e+00","]",",","[","0.00000000e+00",",","0.00000000e+00",",","1.00000000e+00","]","]",")",">",">",">","r.as_euler","(","'zyx","'",",","degrees=True",")","array","(","[","90.",",","0.",",","0",".","]",")","The","`","from_euler","`","function","is","quite","flexible","in","the","range","of","input","formats","it","supports",".","Here","we","initialize","a","single","rotation","about","a","single","axis",":",">",">",">","r","=","R.from_euler","(","'","z","'",",","90",",","degrees=True",")","Again",",","the","object","is","representation","independent","and","can","be","converted","to","any","other","format",":",">",">",">","r.as_quat","(",")","array","(","[","0.",",","0.",",","0.70710678",",","0.70710678","]",")",">",">",">","r.as_dcm","(",")","array","(","[","[","2.22044605e-16",",","-1.00000000e+00",",","0.00000000e+00","]",",","[","1.00000000e+00",",","2.22044605e-16",",","0.00000000e+00","]",",","[","0.00000000e+00",",","0.00000000e+00",",","1.00000000e+00","]","]",")",">",">",">","r.as_rotvec","(",")","array","(","[","0.",",","0.",",","1.57079633","]",")","It","is","also","possible","to","initialize","multiple","rotations","in","a","single","instance","using","any","of","the","`","from_","...","`","functions",".","Here","we","initialize","a","stack","of","3","rotations","using","the","`","from_euler","`","function",":",">",">",">","r","=","R.from_euler","(","'zyx","'",",","[","...","[","90",",","0",",","0","]",",","...","[","0",",","45",",","0","]",",","...","[","45",",","60",",","30","]","]",",","degrees=True",")","The","other","representations","also","now","return","a","stack","of","3","rotations",".","For","example",":",">",">",">","r.as_quat","(",")","array","(","[","[","0.",",","0.",",","0.70710678",",","0.70710678","]",",","[","0.",",","0.38268343",",","0.",",","0.92387953","]",",","[","0.39190384",",","0.36042341",",","0.43967974",",","0.72331741","]","]",")","Applying","the","above","rotations","onto","a","vector",":",">",">",">","v","=","[","1",",","2",",","3","]",">",">",">","r.apply","(","v",")","array","(","[","[","-2.",",","1.",",","3",".","]",",","[","2.82842712",",","2.",",","1.41421356","]",",","[","2.24452282",",","0.78093109",",","2.89002836","]","]",")","A","`","Rotation","`","instance","can","be","indexed","and","sliced","as","if","it","were","a","single","1D","array","or","list",":",">",">",">","r.as_quat","(",")","array","(","[","[","0.",",","0.",",","0.70710678",",","0.70710678","]",",","[","0.",",","0.38268343",",","0.",",","0.92387953","]",",","[","0.39190384",",","0.36042341",",","0.43967974",",","0.72331741","]","]",")",">",">",">","p","=","r","[","0","]",">",">",">","p.as_dcm","(",")","array","(","[","[","2.22044605e-16",",","-1.00000000e+00",",","0.00000000e+00","]",",","[","1.00000000e+00",",","2.22044605e-16",",","0.00000000e+00","]",",","[","0.00000000e+00",",","0.00000000e+00",",","1.00000000e+00","]","]",")",">",">",">","q","=","r","[","1:3","]",">",">",">","q.as_quat","(",")","array","(","[","[","0.",",","0.38268343",",","0.",",","0.92387953","]",",","[","0.39190384",",","0.36042341",",","0.43967974",",","0.72331741","]","]",")","Multiple","rotations","can","be","composed","using","the","`","*","`","operator",":",">",">",">","r1","=","R.from_euler","(","'","z","'",",","90",",","degrees=True",")",">",">",">","r2","=","R.from_rotvec","(","[","np.pi\/4",",","0",",","0","]",")",">",">",">","v","=","[","1",",","2",",","3","]",">",">",">","r2.apply","(","r1.apply","(","v",")",")","array","(","[","-2.",",","-1.41421356",",","2.82842712","]",")",">",">",">","r3","=","r2","*","r1","#","Note","the","order",">",">",">","r3.apply","(","v",")","array","(","[","-2.",",","-1.41421356",",","2.82842712","]",")","Finally",",","it","is","also","possible","to","invert","rotations",":",">",">",">","r1","=","R.from_euler","(","'","z","'",",","[","90",",","45","]",",","degrees=True",")",">",">",">","r2","=","r1.inv","(",")",">",">",">","r2.as_euler","(","'zyx","'",",","degrees=True",")","array","(","[","[","-90.",",","0.",",","0",".","]",",","[","-45.",",","0.",",","0",".","]","]",")","These","examples","serve","as","an","overview","into","the","`","Rotation","`","class","and","highlight","major","functionalities",".","For","more","thorough","examples","of","the","range","of","input","and","output","formats","supported",",","consult","the","individual","method","'s","examples","."]
docstr: Apply this rotation to a set of vectors.
  
  If the original frame rotates to the final frame by this rotation, then
  its application to a vector can be seen in two ways:
  
      - As a projection of vector components expressed in the final frame
        to the original frame.
      - As the physical rotation of a vector being glued to the original
        frame as it rotates. In this case the vector components are
        expressed in the original frame before and after the rotation.
  
  In terms of DCMs, this application is the same as
  `self.as_dcm().dot(vectors)`.
  
  Parameters
  ----------
  vectors : array_like, shape (3,) or (N, 3)
      Each `vectors[i]` represents a vector in 3D space. A single vector
      can either be specified with shape `(3, )` or `(1, 3)`. The number
      of rotations and number of vectors given must follow standard numpy
      broadcasting rules: either one of them equals unity or they both
      equal each other.
  inverse : boolean, optional
      If `inverse` is `True` then the inverse of the rotation(s) is
      applied to the input vectors. Default is `False`.
  
  Returns
  -------
  rotated_vectors : `numpy.ndarray`, shape (3,) or (N, 3)
      Result of applying rotation on input vectors.
      Shape depends on the following cases:
  
          - If object contains a single rotation (as opposed to a stack
            with a single rotation) and a single vector is specified with
            shape `(3,)`, then `output` has shape `(3,)`.
          - In all other cases, `output` has shape `(N, 3)`, where `N` is
            either the number of rotations or vectors.
  
  Examples
  --------
  >>> from scipy.spatial.transform import Rotation as R
  
  Single rotation applied on a single vector:
  
  >>> vector = np.array([1, 0, 0])
  >>> r = R.from_rotvec([0, 0, np.pi/2])
  >>> r.as_dcm()
  array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
         [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
         [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
  >>> r.apply(vector)
  array([2.22044605e-16, 1.00000000e+00, 0.00000000e+00])
  >>> r.apply(vector).shape
  (3,)
  
  Single rotation applied on multiple vectors:
  
  >>> vectors = np.array([
  ... [1, 0, 0],
  ... [1, 2, 3]])
  >>> r = R.from_rotvec([0, 0, np.pi/4])
  >>> r.as_dcm()
  array([[ 0.70710678, -0.70710678,  0.        ],
         [ 0.70710678,  0.70710678,  0.        ],
         [ 0.        ,  0.        ,  1.        ]])
  >>> r.apply(vectors)
  array([[ 0.70710678,  0.70710678,  0.        ],
         [-0.70710678,  2.12132034,  3.        ]])
  >>> r.apply(vectors).shape
  (2, 3)
  
  Multiple rotations on a single vector:
  
  >>> r = R.from_rotvec([[0, 0, np.pi/4], [np.pi/2, 0, 0]])
  >>> vector = np.array([1,2,3])
  >>> r.as_dcm()
  array([[[ 7.07106781e-01, -7.07106781e-01,  0.00000000e+00],
          [ 7.07106781e-01,  7.07106781e-01,  0.00000000e+00],
          [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]],
         [[ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
          [ 0.00000000e+00,  2.22044605e-16, -1.00000000e+00],
          [ 0.00000000e+00,  1.00000000e+00,  2.22044605e-16]]])
  >>> r.apply(vector)
  array([[-0.70710678,  2.12132034,  3.        ],
         [ 1.        , -3.        ,  2.        ]])
  >>> r.apply(vector).shape
  (2, 3)
  
  Multiple rotations on multiple vectors. Each rotation is applied on the
  corresponding vector:
  
  >>> r = R.from_euler('zxy', [
  ... [0, 0, 90],
  ... [45, 30, 60]], degrees=True)
  >>> vectors = [
  ... [1, 2, 3],
  ... [1, 0, -1]]
  >>> r.apply(vectors)
  array([[ 3.        ,  2.        , -1.        ],
         [-0.09026039,  1.11237244, -0.86860844]])
  >>> r.apply(vectors).shape
  (2, 3)
  
  It is also possible to apply the inverse rotation:
  
  >>> r = R.from_euler('zxy', [
  ... [0, 0, 90],
  ... [45, 30, 60]], degrees=True)
  >>> vectors = [
  ... [1, 2, 3],
  ... [1, 0, -1]]
  >>> r.apply(vectors, inverse=True)
  array([[-3.        ,  2.        ,  1.        ],
         [ 1.09533535, -0.8365163 ,  0.3169873 ]])
docstr_tok: ["Apply","this","rotation","to","a","set","of","vectors",".","If","the","original","frame","rotates","to","the","final","frame","by","this","rotation",",","then","its","application","to","a","vector","can","be","seen","in","two","ways",":","-","As","a","projection","of","vector","components","expressed","in","the","final","frame","to","the","original","frame",".","-","As","the","physical","rotation","of","a","vector","being","glued","to","the","original","frame","as","it","rotates",".","In","this","case","the","vector","components","are","expressed","in","the","original","frame","before","and","after","the","rotation",".","In","terms","of","DCMs",",","this","application","is","the","same","as","`","self.as_dcm","(",")",".dot","(","vectors",")","`",".","Parameters","--","--","--","--","--","vectors",":","array_like",",","shape","(","3",",",")","or","(","N",",","3",")","Each","`","vectors","[","i","]","`","represents","a","vector","in","3D","space",".","A","single","vector","can","either","be","specified","with","shape","`","(","3",",",")","`","or","`","(","1",",","3",")","`",".","The","number","of","rotations","and","number","of","vectors","given","must","follow","standard","numpy","broadcasting","rules",":","either","one","of","them","equals","unity","or","they","both","equal","each","other",".","inverse",":","boolean",",","optional","If","`","inverse","`","is","`","True","`","then","the","inverse","of","the","rotation","(","s",")","is","applied","to","the","input","vectors",".","Default","is","`","False","`",".","Returns","--","--","--","-","rotated_vectors",":","`","numpy.ndarray","`",",","shape","(","3",",",")","or","(","N",",","3",")","Result","of","applying","rotation","on","input","vectors",".","Shape","depends","on","the","following","cases",":","-","If","object","contains","a","single","rotation","(","as","opposed","to","a","stack","with","a","single","rotation",")","and","a","single","vector","is","specified","with","shape","`","(","3",",",")","`",",","then","`","output","`","has","shape","`","(","3",",",")","`",".","-","In","all","other","cases",",","`","output","`","has","shape","`","(","N",",","3",")","`",",","where","`","N","`","is","either","the","number","of","rotations","or","vectors",".","Examples","--","--","--","--",">",">",">","from","scipy.spatial.transform","import","Rotation","as","R","Single","rotation","applied","on","a","single","vector",":",">",">",">","vector","=","np.array","(","[","1",",","0",",","0","]",")",">",">",">","r","=","R.from_rotvec","(","[","0",",","0",",","np.pi\/2","]",")",">",">",">","r.as_dcm","(",")","array","(","[","[","2.22044605e-16",",","-1.00000000e+00",",","0.00000000e+00","]",",","[","1.00000000e+00",",","2.22044605e-16",",","0.00000000e+00","]",",","[","0.00000000e+00",",","0.00000000e+00",",","1.00000000e+00","]","]",")",">",">",">","r.apply","(","vector",")","array","(","[","2.22044605e-16",",","1.00000000e+00",",","0.00000000e+00","]",")",">",">",">","r.apply","(","vector",")",".shape","(","3",",",")","Single","rotation","applied","on","multiple","vectors",":",">",">",">","vectors","=","np.array","(","[","...","[","1",",","0",",","0","]",",","...","[","1",",","2",",","3","]","]",")",">",">",">","r","=","R.from_rotvec","(","[","0",",","0",",","np.pi\/4","]",")",">",">",">","r.as_dcm","(",")","array","(","[","[","0.70710678",",","-0.70710678",",","0",".","]",",","[","0.70710678",",","0.70710678",",","0",".","]",",","[","0.",",","0.",",","1",".","]","]",")",">",">",">","r.apply","(","vectors",")","array","(","[","[","0.70710678",",","0.70710678",",","0",".","]",",","[","-0.70710678",",","2.12132034",",","3",".","]","]",")",">",">",">","r.apply","(","vectors",")",".shape","(","2",",","3",")","Multiple","rotations","on","a","single","vector",":",">",">",">","r","=","R.from_rotvec","(","[","[","0",",","0",",","np.pi\/4","]",",","[","np.pi\/2",",","0",",","0","]","]",")",">",">",">","vector","=","np.array","(","[","1,2,3","]",")",">",">",">","r.as_dcm","(",")","array","(","[","[","[","7.07106781e-01",",","-7.07106781e-01",",","0.00000000e+00","]",",","[","7.07106781e-01",",","7.07106781e-01",",","0.00000000e+00","]",",","[","0.00000000e+00",",","0.00000000e+00",",","1.00000000e+00","]","]",",","[","[","1.00000000e+00",",","0.00000000e+00",",","0.00000000e+00","]",",","[","0.00000000e+00",",","2.22044605e-16",",","-1.00000000e+00","]",",","[","0.00000000e+00",",","1.00000000e+00",",","2.22044605e-16","]","]","]",")",">",">",">","r.apply","(","vector",")","array","(","[","[","-0.70710678",",","2.12132034",",","3",".","]",",","[","1.",",","-3.",",","2",".","]","]",")",">",">",">","r.apply","(","vector",")",".shape","(","2",",","3",")","Multiple","rotations","on","multiple","vectors",".","Each","rotation","is","applied","on","the","corresponding","vector",":",">",">",">","r","=","R.from_euler","(","'zxy","'",",","[","...","[","0",",","0",",","90","]",",","...","[","45",",","30",",","60","]","]",",","degrees=True",")",">",">",">","vectors","=","[","...","[","1",",","2",",","3","]",",","...","[","1",",","0",",","-1","]","]",">",">",">","r.apply","(","vectors",")","array","(","[","[","3.",",","2.",",","-1",".","]",",","[","-0.09026039",",","1.11237244",",","-0.86860844","]","]",")",">",">",">","r.apply","(","vectors",")",".shape","(","2",",","3",")","It","is","also","possible","to","apply","the","inverse","rotation",":",">",">",">","r","=","R.from_euler","(","'zxy","'",",","[","...","[","0",",","0",",","90","]",",","...","[","45",",","30",",","60","]","]",",","degrees=True",")",">",">",">","vectors","=","[","...","[","1",",","2",",","3","]",",","...","[","1",",","0",",","-1","]","]",">",">",">","r.apply","(","vectors",",","inverse=True",")","array","(","[","[","-3.",",","2.",",","1",".","]",",","[","1.09533535",",","-0.8365163",",","0.3169873","]","]",")"]
code: def apply(self, vectors, inverse=False):
      """Apply this rotation to a set of vectors.
  
      If the original frame rotates to the final frame by this rotation, then
      its application to a vector can be seen in two ways:
  
          - As a projection of vector components expressed in the final frame
            to the original frame.
          - As the physical rotation of a vector being glued to the original
            frame as it rotates. In this case the vector components are
            expressed in the original frame before and after the rotation.
  
      In terms of DCMs, this application is the same as
      `self.as_dcm().dot(vectors)`.
  
      Parameters
      ----------
      vectors : array_like, shape (3,) or (N, 3)
          Each `vectors[i]` represents a vector in 3D space. A single vector
          can either be specified with shape `(3, )` or `(1, 3)`. The number
          of rotations and number of vectors given must follow standard numpy
          broadcasting rules: either one of them equals unity or they both
          equal each other.
      inverse : boolean, optional
          If `inverse` is `True` then the inverse of the rotation(s) is
          applied to the input vectors. Default is `False`.
  
      Returns
      -------
      rotated_vectors : `numpy.ndarray`, shape (3,) or (N, 3)
          Result of applying rotation on input vectors.
          Shape depends on the following cases:
  
              - If object contains a single rotation (as opposed to a stack
                with a single rotation) and a single vector is specified with
                shape `(3,)`, then `output` has shape `(3,)`.
              - In all other cases, `output` has shape `(N, 3)`, where `N` is
                either the number of rotations or vectors.
  
      Examples
      --------
      >>> from scipy.spatial.transform import Rotation as R
  
      Single rotation applied on a single vector:
  
      >>> vector = np.array([1, 0, 0])
      >>> r = R.from_rotvec([0, 0, np.pi/2])
      >>> r.as_dcm()
      array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
             [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
             [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
      >>> r.apply(vector)
      array([2.22044605e-16, 1.00000000e+00, 0.00000000e+00])
      >>> r.apply(vector).shape
      (3,)
  
      Single rotation applied on multiple vectors:
  
      >>> vectors = np.array([
      ... [1, 0, 0],
      ... [1, 2, 3]])
      >>> r = R.from_rotvec([0, 0, np.pi/4])
      >>> r.as_dcm()
      array([[ 0.70710678, -0.70710678,  0.        ],
             [ 0.70710678,  0.70710678,  0.        ],
             [ 0.        ,  0.        ,  1.        ]])
      >>> r.apply(vectors)
      array([[ 0.70710678,  0.70710678,  0.        ],
             [-0.70710678,  2.12132034,  3.        ]])
      >>> r.apply(vectors).shape
      (2, 3)
  
      Multiple rotations on a single vector:
  
      >>> r = R.from_rotvec([[0, 0, np.pi/4], [np.pi/2, 0, 0]])
      >>> vector = np.array([1,2,3])
      >>> r.as_dcm()
      array([[[ 7.07106781e-01, -7.07106781e-01,  0.00000000e+00],
              [ 7.07106781e-01,  7.07106781e-01,  0.00000000e+00],
              [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]],
             [[ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
              [ 0.00000000e+00,  2.22044605e-16, -1.00000000e+00],
              [ 0.00000000e+00,  1.00000000e+00,  2.22044605e-16]]])
      >>> r.apply(vector)
      array([[-0.70710678,  2.12132034,  3.        ],
             [ 1.        , -3.        ,  2.        ]])
      >>> r.apply(vector).shape
      (2, 3)
  
      Multiple rotations on multiple vectors. Each rotation is applied on the
      corresponding vector:
  
      >>> r = R.from_euler('zxy', [
      ... [0, 0, 90],
      ... [45, 30, 60]], degrees=True)
      >>> vectors = [
      ... [1, 2, 3],
      ... [1, 0, -1]]
      >>> r.apply(vectors)
      array([[ 3.        ,  2.        , -1.        ],
             [-0.09026039,  1.11237244, -0.86860844]])
      >>> r.apply(vectors).shape
      (2, 3)
  
      It is also possible to apply the inverse rotation:
  
      >>> r = R.from_euler('zxy', [
      ... [0, 0, 90],
      ... [45, 30, 60]], degrees=True)
      >>> vectors = [
      ... [1, 2, 3],
      ... [1, 0, -1]]
      >>> r.apply(vectors, inverse=True)
      array([[-3.        ,  2.        ,  1.        ],
             [ 1.09533535, -0.8365163 ,  0.3169873 ]])
  
      """
      vectors = np.asarray(vectors)
      if vectors.ndim > 2 or vectors.shape[-1] != 3:
          raise ValueError(
              "Expected input of shape (3,) or (P, 3), "
              "got {}.".format(vectors.shape)
          )
  
      single_vector = False
      if vectors.shape == (3,):
          single_vector = True
          vectors = vectors[None, :]
  
      dcm = self.as_dcm()
      if self._single:
          dcm = dcm[None, :, :]
  
      n_vectors = vectors.shape[0]
      n_rotations = len(self)
  
      if (
          n_vectors != 1
          and n_rotations != 1
          and n_vectors != n_rotations
      ):
          raise ValueError(
              "Expected equal numbers of rotations and vectors "
              ", or a single rotation, or a single vector, got "
              "{} rotations and {} vectors.".format(
                  n_rotations, n_vectors
              )
          )
  
      if inverse:
          result = np.einsum("ikj,ik->ij", dcm, vectors)
      else:
          result = np.einsum("ijk,ik->ij", dcm, vectors)
  
      if self._single and single_vector:
          return result[0]
      else:
          return result
  
imports: from __future__ import division, print_function, absolute_import
  import re
  import warnings
  import numpy
  import scipy.linalg
  from scipy._lib._util import check_random_state
label_desc: Use image node_id 11 for calling the Rotation obj's underlying member method code with example usage: obj.apply(vectors, inverse) and returns: result, result