Esempio n. 1
0
        bool IsAxisCollision(RotatedRectangle rectangle, Vector2 axis)
        {
            var scalars          = Scalars(axis);
            var rectangleScalars = rectangle.Scalars(axis);

            if ((scalars[0] <= rectangleScalars[1]) && (scalars[1] >= rectangleScalars[1]))
            {
                return(true);
            }
            return((rectangleScalars[0] <= scalars[1]) && (rectangleScalars[1] >= scalars[1]));
        }
Esempio n. 2
0
        public bool Intersects(RotatedRectangle rectangle)
        {
            var rAxis = new Vector2[4]
            {
                (TopRight - TopLeft),
                (TopRight - BottomRight),
                (rectangle.TopLeft - rectangle.BottomLeft),
                (rectangle.TopLeft - rectangle.TopRight)
            };

            foreach (var axis in rAxis)
            {
                if (!IsAxisCollision(rectangle, axis))
                {
                    return(false);
                }
            }
            return(true);
        }