Beispiel #1
0
        public bool SeparatingAxisForRectangle(Rectangle rectangle)
        {
            IVector2D n = Point1.Substract(Point2);

            var rEdgeA = new LineSegment(rectangle.Corner(0), rectangle.Corner(1));
            var rEdgeB = new LineSegment(rectangle.Corner(2), rectangle.Corner(3));

            Range rEdgeARange = rEdgeA.ProjectOnto(n);
            Range rEdgeBRange = rEdgeB.ProjectOnto(n);
            Range rProjection = rEdgeARange.Hull(rEdgeBRange);

            Range axisRange = ProjectOnto(n);

            return !axisRange.Overlaps(rProjection);
        }