title: Converting Math functions from Python to c++
body: <p>I am attempting to convert some opencv code from python to c++, and am a little lost. The python is:</p>
  
  <pre><code>if 0 &lt; R[1,1] &lt; 1:
      # If it gets here, the pose is flipped.
  
      # Flip the axes. E.g., Y axis becomes [-y0, -y1, y2].
      R *= np.array([
          [ 1, -1,  1],
          [ 1, -1,  1],
          [-1,  1, -1],
      ])
  
      # Fixup: rotate along the plane spanned by camera's forward (Z) axis and vector to marker's position
      forward = np.array([0, 0, 1])
      tnorm = T / np.linalg.norm(T)
      axis = np.cross(tnorm, forward)
      angle = -2*math.acos(tnorm @ forward)
      R = cv2.Rodrigues(angle * axis)[0] @ R
  </code></pre>
  
  <p>So far i have:</p>
  
  <pre><code>cv::Mat R;
  if (0 &lt; R.at&lt;double&gt;(1, 1) &lt; 1) {
  
              // Flip the axes.E.g., Y axis becomes[-y0, -y1, y2].
              float mult[9] = { 1, -1, 1, 1, -1, 1,-1, 1, -1 };
  
              cv::Mat FlipAxes = cv::Mat(3, 3, CV_32F, mult);
  
              R *= FlipAxes;
  
                  //# Fixup: rotate along the plane spanned by camera's forward (Z) axis and vector to marker's position
              cv::Vec3d forward(0, 0, 1);
              double tnorm = tvecBest / np.linalg.norm(T)
              axis = np.cross(tnorm, forward)
              angle = -2 * math.acos(tnorm @ forward)
              R = cv2.Rodrigues(angle * axis)[0] * R
  
  
          }
  </code></pre>
  
  <p>I am lost on these lines:</p>
  
  <pre><code>double tnorm = tvecBest / np.linalg.norm(T)
  axis = np.cross(tnorm, forward)
  angle = -2 * math.acos(tnorm @ forward)
  </code></pre>
  
  <p>what is the equivalent of <code>np.linalg.norm</code> in c++ opencv?</p>