I want to rotate point around an arbitrary point using transformation matrix.
So the equations are:
p'x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox
p'y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy
But I want to rewrite it in form of matrix transforms, it seems like it should be (c=cos(theta),s=sin(theta)):

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.
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?