Example #1
0
        public bool CollidesWith(OrientedRectangle orientedRectangle)
        {
            var edge = this.Edge(0);

            if (orientedRectangle.IsSeparatingAxis(edge))
            {
                return(false);
            }

            edge = this.Edge(1);
            if (orientedRectangle.IsSeparatingAxis(edge))
            {
                return(false);
            }

            edge = orientedRectangle.Edge(0);
            if (this.IsSeparatingAxis(edge))
            {
                return(false);
            }

            edge = orientedRectangle.Edge(1);
            if (this.IsSeparatingAxis(edge))
            {
                return(false);
            }

            return(true);
        }
        public bool CollidesWith(OrientedRectangle orientedRectangle)
        {
            LineSegment edge = Edge(0);

            if (edge.SeparatingAxisForOrientedRectangle(orientedRectangle))
            {
                return false;
            }

            edge = Edge(1);
            if (edge.SeparatingAxisForOrientedRectangle(orientedRectangle))
            {
                return false;
            }

            edge = orientedRectangle.Edge(0);

            if (edge.SeparatingAxisForOrientedRectangle(this))
            {
                return false;
            }

            edge = orientedRectangle.Edge(1);

            return !edge.SeparatingAxisForOrientedRectangle(this);
        }
Example #3
0
        public bool CollidesWith(OrientedRectangle orientedRectangle)
        {
            var orHull = orientedRectangle.GetRectangleHull();

            if (!orHull.CollidesWith(this))
            {
                return(false);
            }

            var edge = orientedRectangle.Edge(0);

            if (this.IsSeparatingAxis(edge))
            {
                return(false);
            }

            edge = orientedRectangle.Edge(1);
            if (this.IsSeparatingAxis(edge))
            {
                return(false);
            }

            return(true);
        }
Example #4
0
        public bool CollidesWith(OrientedRectangle orientedRectangle)
        {
            Rectangle orHull = orientedRectangle.RectangleHull();
            if (!orHull.CollidesWith(this))
            {
                return false;
            }

            LineSegment edge = orientedRectangle.Edge(0);
            if (edge.SeparatingAxisForRectangle(this))
            {
                return false;
            }

            edge = orientedRectangle.Edge(1);

            return !edge.SeparatingAxisForRectangle(this);
        }
Example #5
0
        public bool SeparatingAxisForOrientedRectangle(OrientedRectangle orientedRectangle)
        {
            LineSegment rEdge0 = orientedRectangle.Edge(0);
            LineSegment rEdge2 = orientedRectangle.Edge(2);
            IVector2D n = Point1.Substract(Point2);

            Range axisRange = ProjectOnto(n);
            Range r0Range = rEdge0.ProjectOnto(n);
            Range r2Range = rEdge2.ProjectOnto(n);
            Range rProjection = r0Range.Hull(r2Range);

            return !axisRange.Overlaps(rProjection);
        }