title: OpenCV, Rotation around specific point
body: <p>I am trying to rotate four points(rectangle) around the middle point of them.
  But the result looks strange.
  I use the formula found here and on wikipedia</p>
  
  <pre><code>p.x'=p.x*cos(alpha) + p.y*sin(alpha);
  
  p.y'=(-1)p.x*sin(alpha) + p.y*cos(alpha);
  </code></pre>
  
  <p>Is this formula applicable for my purpose (rotating rectangle)?</p>
  
  <p>Here is the source, I try to rotate 33 degrees counter clockwise</p>
  
  <p>Thank You, very much</p>
  
  <pre><code>Mat img(480, 800, CV_8UC4, Scalar(255,255,255,255));
  Mat dst(480, 800, CV_8UC4, Scalar(255,255,255,255));
  
  Point p1, p2, p3, p4;
  Point center;
  
  p1.x=501; p1.y=247;
  p2.x=429; p2.y=291;
  p3.x=388; p3.y=222;
  p4.x=451; p4.y=186;
  
  circle(img, p1, 3, Scalar(255, 0, 0, 255), 3, 8, 0 );
  circle(img, p2, 3, Scalar(0, 255, 0, 255), 3, 8, 0 );
  circle(img, p3, 3, Scalar(0, 0, 255, 255), 3, 8, 0 );
  circle(img, p4, 3, Scalar(255, 255, 0, 255), 3, 8, 0 );
  
  center.x = (p1.x+p2.x+p3.x+p4.x)/4;
  center.y = (p1.y+p2.y+p3.y+p4.y)/4;
  
  
  double alpha = -33 * 0.0174532925;
  double s = sin(alpha);
  double c = cos(alpha);
  
  p1.x = (+c*(p1.x-center.x)* + s*(p1.y-center.y)) + center.x;
  p1.y = (-s*(p1.x-center.x) + c*(p1.y-center.y)) + center.y;
  p2.x = (+c*(p2.x-center.x)* + s*(p2.y-center.y)) + center.x;
  p2.y = (-s*(p2.x-center.x) + c*(p2.y-center.y)) + center.y;
  p3.x = (+c*(p3.x-center.x)* + s*(p3.y-center.y)) + center.x;
  p3.y = (-s*(p3.x-center.x) + c*(p3.y-center.y)) + center.y;
  p4.x = (+c*(p4.x-center.x)* + s*(p4.y-center.y)) + center.x;
  p4.y = (-s*(p4.x-center.x) + c*(p4.y-center.y)) + center.y;
  
  circle(dst, p1, 3, Scalar(255, 0, 0, 255), 3, 8, 0 );
  circle(dst, p2, 3, Scalar(0, 255, 0, 255), 3, 8, 0 );
  circle(dst, p3, 3, Scalar(0, 0, 255, 255), 3, 8, 0 );
  circle(dst, p4, 3, Scalar(255, 255, 0, 255), 3, 8, 0 );
  
  imshow("src", img);
  imshow("dst", dst);
  cvMoveWindow("dst", 0, img.cols+50);
  
  waitKey(0);
  return 0;
  </code></pre>