title: Rotation around an arbitrary point using transformation matrix
body: <p>I want to rotate point around an arbitrary point using transformation matrix.</p>
  
  <p>So the equations are:</p>
  
  <pre><code>p'x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox
  p'y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy
  </code></pre>
  
  <p>But I want to rewrite it in form of matrix transforms, it seems like it should be (c=cos(theta),s=sin(theta)):</p>
  
  <p><img src="https://i.stack.imgur.com/487Uu.gif" alt=""></p>
  
  <p>By default, the rotation matrix uses the origin point as the center of the rotation. To rotate around an arbitrary point, you have to subtract the distance to the origin using a translation matrix, do the rotation, and then translate back.</p>
  
  <p>If I understand it right first we subtract from original point to make ot (0,0), then rotate around point (0,0) and then add to result point, but I think that 1st and 3rd matrix must be swapped?</p>