Guest User

Untitled

a guest
Apr 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. public void RotatePolygon(Point current)
  2.         {
  3.             Point center = GetPolygonCenter();
  4.             double angle = Math.Atan((double)(current.Y - center.Y) / (double)(current.X - center.X));
  5.             List<Point> tmpVertexs = new List<Point>();
  6.             foreach (Point p in Vertexs)
  7.             {
  8.                 int tmpX = 0, tmpY = 0;
  9.                 tmpX = Math.Abs((int)((p.X - center.X) * Math.Cos(angle * Math.PI / 180) - (p.Y - center.Y) * Math.Sin(angle * Math.PI / 180)));
  10.                 tmpY = Math.Abs((int)((p.Y - center.Y) * Math.Cos(angle * Math.PI / 180) + (p.X - center.X) * Math.Sin(angle * Math.PI / 180)));
  11.                 tmpX += p.X - center.X;
  12.                 tmpY += p.Y - center.Y;
  13.                 tmpVertexs.Add(new Point(tmpX, tmpY));
  14.             }
  15.  
  16.             Vertexs = tmpVertexs;
  17.         }
Add Comment
Please, Sign In to add comment