Advertisement
Guest User

Координаты вершин

a guest
Nov 8th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1.         public static Point Rotate(Point pointToRotate, Point center, double angle)
  2.         {
  3.             return
  4.                 new Point(
  5.                     (float)(center.X + (pointToRotate.X - center.X) * Math.Cos(angle) +
  6.                              (center.Y - pointToRotate.Y) * Math.Sin(angle)),
  7.                     (float)(center.Y + (pointToRotate.X - center.X) * Math.Sin(angle) +
  8.                              (pointToRotate.Y - center.Y) * Math.Cos(angle)));
  9.         }
  10.  
  11.         public static Point[] GetPoints(ObstacleT unit)
  12.         {
  13.             return new[]
  14.                        {
  15.                            Rotate(new Point(unit.X - unit.Width/2, unit.Y + unit.Height/2),
  16.                                   new Point(unit.X, unit.Y), unit.Angle),
  17.                            Rotate(new Point(unit.X + unit.Width/2, unit.Y + unit.Height/2),
  18.                                   new Point(unit.X, unit.Y), unit.Angle),
  19.                            Rotate(new Point(unit.X + unit.Width/2, unit.Y - unit.Height/2),
  20.                                   new Point(unit.X, unit.Y), unit.Angle),
  21.                            Rotate(new Point(unit.X - unit.Width/2, unit.Y - unit.Height/2),
  22.                                   new Point(unit.X, unit.Y), unit.Angle)
  23.                        };
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement