title: rotation matrix in openCV
body: <p>I am creating a rotation matrix in python as follows:</p>
  
  <pre><code>import numpy as np
  def make_rot(angle):
      cost = np.cos(np.deg2rad(angle))
      sint = np.sin(np.deg2rad(angle))
      rot = np.array([[cost, -sint, 0],
                     [sint, cost, 0],
                     [0, 0, 1]])
      return rot
  </code></pre>
  
  <p>This is as defined in the wikipedia page here: <a href="http://en.wikipedia.org/wiki/Rotation_matrix" rel="noreferrer">http://en.wikipedia.org/wiki/Rotation_matrix</a></p>
  
  <p>I run it with the angle parameter as 45 degrees and I get something like:</p>
  
  <pre><code>[[ 0.70710678 -0.70710678  0.        ]
   [ 0.70710678  0.70710678  0.        ]
   [ 0.          0.          1.        ]]
  </code></pre>
  
  <p>Now, I use the OpenCV <code>getRotationMatrix2D</code> API as follows:</p>
  
  <pre><code>import cv2
  M = cv2.getRotationMatrix2D((0, 0), 45, 1)
  </code></pre>
  
  <p>The matrix I get is the inverse of the matrix (the transpose as it is a rotation matrix). The result is as follows:</p>
  
  <pre><code>[[ 0.70710678  0.70710678  0.        ]
   [-0.70710678  0.70710678  0.        ]]
  </code></pre>
  
  <p>As you can see it is the inverse. I have not found anything in the OpenCV documentation which says anything about this behaviour.</p>
  
  <p>Now, I can use this matrix in OpenCV and <code>skimage</code> to transform an image as follows:</p>
  
  <pre><code># openCV
  M = cv2.getRotationMatrix2D((0, 0), 45, 1)
  dst = cv2.warpAffine(image2, M, (coumns, rows))
  
  # skimage
  from skimage import transform as tf
  tform = tf.AffineTransform(matrix=make_rot(45))
  dst = tf.warp(image_2, tform)
  </code></pre>
  
  <p>The surprising thing is that the result from using my matrix and OpenCV matrix is the same. </p>
  
  <p>My question is why is OpenCV working with the inverse of the transformation? I am wondering if this is something they are not mentioning in the documentation or if I am using this wrong somehow.</p>