예제 #1
0
        private void applyTransform()
        {
            TransformValid = true;
            Vector2 low  = new Vector2();
            Vector2 high = new Vector2();

            for (int i = 0; i < corners.Length; i++)
            {
                RealCorners[i]    = LocationManager.TransformAround(Vector2.Zero, corners[i], rotation);
                RealCorners[i].X += position.X;
                RealCorners[i].Y += position.Y;
                if (i == 0)
                {
                    low  = new Vector2(RealCorners[i].X, RealCorners[i].Y);
                    high = new Vector2(RealCorners[i].X, RealCorners[i].Y);
                }
                else
                {
                    low.X  = Math.Min(RealCorners[i].X, low.X);
                    low.Y  = Math.Min(RealCorners[i].Y, low.Y);
                    high.X = Math.Max(RealCorners[i].X, high.X);
                    high.Y = Math.Max(RealCorners[i].Y, high.Y);
                }
            }
            bounds = new Rectangle((int)low.X, (int)low.Y, (int)(high.X - low.X), (int)(high.Y - low.Y));
        }
예제 #2
0
        public Vector2[] GetCorners()
        {
            Vector2[] coords = { new Vector2(-(Width / 2), -(Height / 2)),
                                 new Vector2(-(Width / 2), (Height / 2)),
                                 new Vector2((Width / 2),  (Height / 2)),
                                 new Vector2((Width / 2), -(Height / 2)) };
            for (int i = 0; i < 4; i++)
            {
                coords[i]    = LocationManager.TransformAround(Vector2.Zero, coords[i], Rotation);
                coords[i].X += X;
                coords[i].Y += Y;
            }

            return(coords);
        }
예제 #3
0
 public Vector2[] RelativeLine(Vector2[] GlobalLine, Vector2 Position, float CurrentRotation)
 {
     return(new Vector2[] { LocationManager.TransformAround(Position, GlobalLine[0], CurrentRotation) - Position,
                            LocationManager.TransformAround(Position, GlobalLine[1], CurrentRotation) - Position });
 }