parameters: (R)
return_statement: return [x,y,z]
docstring: Returns the rotation vector w (exponential map) representation of R such
      that e^[w] = R.  Equivalent to axis-angle representation with
      w/||w||=axis, ||w||=angle.
docstring_summary: Returns the rotation vector w (exponential map) representation of R such
      that e^[w] = R.  Equivalent to axis-angle representation with
      w/||w||=axis, ||w||=angle.
docstring_tokens: Returns the rotation vector w ( exponential map ) representation of R such that e^ [ w ] = R . Equivalent to axis - angle representation with w / ||w|| = axis ||w|| = angle .
function: def rotation_vector(R):
      """Returns the rotation vector w (exponential map) representation of R such
      that e^[w] = R.  Equivalent to axis-angle representation with
      w/||w||=axis, ||w||=angle."""
      theta = angle(R)
      if abs(theta-math.pi)<0.5:
          #for values close to pi this alternate technique has better numerical
          #performance
          c = math.cos(theta)
          x2=(R[0]-c)/(1.0 - c)
          y2=(R[4]-c)/(1.0 - c)
          z2=(R[8]-c)/(1.0 - c)
          if x2 < 0:
              assert(x2>-1e-5)
              x2=0
          if y2 < 0:
              assert(y2>-1e-5)
              y2=0
          if z2 < 0:
              assert(z2>-1e-5)
              z2=0
          x = theta*math.sqrt(x2)
          y = theta*math.sqrt(y2)
          z = theta*math.sqrt(z2)
          if abs(theta-math.pi) < 1e-5:
              #determined up to sign changes, we know r12=2xy,r13=2xz,r23=2yz
              xy=R[3]
              xz=R[6]
              yz=R[7]
              if(x > y):
                  if(x > z):
                      #x is largest
                      if(xy < 0): y=-y
                      if(xz < 0): z=-z
                  else:
                      #z is largest
                      if(yz < 0): y=-y
                      if(xz < 0): x=-x
              else:
                  if(y > z):
                      #y is largest
                      if(xy < 0): x=-x
                      if(yz < 0): z=-z
                  else:
                      #z is largest
                      if(yz < 0): y=-y
                      if(xz < 0): x=-x
          else:
              #alternate technique: use sign of anti-cross product
              eps = theta-math.pi
              if eps*(R[3+2]-R[6+1]) > 0:
                  x = -x
              if eps*(R[6+0]-R[0+2]) > 0:
                  y = -y
              if eps*(R[0+1]-R[3+0]) > 0:
                  z = -z
          return [x,y,z]
      #normal
      scale = 0.5
      if abs(theta) > 1e-5:
          scale = 0.5*theta/math.sin(theta)
      x = (R[3+2]-R[6+1]) * scale;
      y = (R[6+0]-R[0+2]) * scale;
      z = (R[0+1]-R[3+0]) * scale;
      return [x,y,z]
function_tokens: def rotation_vector ( R ) : theta = angle ( R ) if abs ( theta - math . pi ) < 0.5 : #for values close to pi this alternate technique has better numerical #performance c = math . cos ( theta ) x2 = ( R [ 0 ] - c ) / ( 1.0 - c ) y2 = ( R [ 4 ] - c ) / ( 1.0 - c ) z2 = ( R [ 8 ] - c ) / ( 1.0 - c ) if x2 < 0 : assert ( x2 > - 1e-5 ) x2 = 0 if y2 < 0 : assert ( y2 > - 1e-5 ) y2 = 0 if z2 < 0 : assert ( z2 > - 1e-5 ) z2 = 0 x = theta * math . sqrt ( x2 ) y = theta * math . sqrt ( y2 ) z = theta * math . sqrt ( z2 ) if abs ( theta - math . pi ) < 1e-5 : #determined up to sign changes, we know r12=2xy,r13=2xz,r23=2yz xy = R [ 3 ] xz = R [ 6 ] yz = R [ 7 ] if ( x > y ) : if ( x > z ) : #x is largest if ( xy < 0 ) : y = - y if ( xz < 0 ) : z = - z else : #z is largest if ( yz < 0 ) : y = - y if ( xz < 0 ) : x = - x else : if ( y > z ) : #y is largest if ( xy < 0 ) : x = - x if ( yz < 0 ) : z = - z else : #z is largest if ( yz < 0 ) : y = - y if ( xz < 0 ) : x = - x else : #alternate technique: use sign of anti-cross product eps = theta - math . pi if eps * ( R [ 3 + 2 ] - R [ 6 + 1 ] ) > 0 : x = - x if eps * ( R [ 6 + 0 ] - R [ 0 + 2 ] ) > 0 : y = - y if eps * ( R [ 0 + 1 ] - R [ 3 + 0 ] ) > 0 : z = - z return [ x , y , z ] #normal scale = 0.5 if abs ( theta ) > 1e-5 : scale = 0.5 * theta / math . sin ( theta ) x = ( R [ 3 + 2 ] - R [ 6 + 1 ] ) * scale y = ( R [ 6 + 0 ] - R [ 0 + 2 ] ) * scale z = ( R [ 0 + 1 ] - R [ 3 + 0 ] ) * scale return [ x , y , z ]