Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RotatePolygon(Point current)
- {
- Point center = GetPolygonCenter();
- double angle = Math.Atan((double)(current.Y - center.Y) / (double)(current.X - center.X));
- List<Point> tmpVertexs = new List<Point>();
- foreach (Point p in Vertexs)
- {
- int tmpX = 0, tmpY = 0;
- tmpX = Math.Abs((int)((p.X - center.X) * Math.Cos(angle * Math.PI / 180) - (p.Y - center.Y) * Math.Sin(angle * Math.PI / 180)));
- tmpY = Math.Abs((int)((p.Y - center.Y) * Math.Cos(angle * Math.PI / 180) + (p.X - center.X) * Math.Sin(angle * Math.PI / 180)));
- tmpX += p.X - center.X;
- tmpY += p.Y - center.Y;
- tmpVertexs.Add(new Point(tmpX, tmpY));
- }
- Vertexs = tmpVertexs;
- }
Add Comment
Please, Sign In to add comment