Exemplo n.º 1
0
        public bool DoesLocusIntersect(Loci pobjTarget)
        {
            PointF point = new PointF(0, 0);

            switch (this.Type)
            {
            case LociType.Line:
                switch (pobjTarget.Type)
                {
                case LociType.Line:
                    return(IntersectionHelpers.DoLinesIntersect(this.Line, pobjTarget.Line, ref point));

                case LociType.Point:
                    return(IntersectionHelpers.DoLinesIntersect(this.Line, pobjTarget.CreateLineFromPoint(), ref point));

                case LociType.Rectangle:
                    return(IntersectionHelpers.DoesLineIntersectRectangle(pobjTarget.Rectangle, this.Line));
                }
                break;

            case LociType.Point:
                switch (pobjTarget.Type)
                {
                case LociType.Line:
                    return(IntersectionHelpers.DoLinesIntersect(pobjTarget.Line, this.CreateLineFromPoint(), ref point));

                case LociType.Point:
                    return(this.Point.Equals(pobjTarget.Point));

                case LociType.Rectangle:
                    return(pobjTarget.Rectangle.Contains(this.Point));
                }
                break;

            case LociType.Rectangle:
                switch (pobjTarget.Type)
                {
                case LociType.Line:
                    return(IntersectionHelpers.DoesLineIntersectRectangle(this.Rectangle, pobjTarget.Line));

                case LociType.Point:
                    return(this.Rectangle.Contains(pobjTarget.Point));

                case LociType.Rectangle:
                    return(pobjTarget.Rectangle.IntersectsWith(this.Rectangle));
                }
                break;
            }

            throw new NotSupportedException();
        }
Exemplo n.º 2
0
        /// <returns>Returns the loci which describes the intersection. WARNING: Where points are concerned it is assumed the point does intersect so the point simply gets returned. This is to prevent multiple calls to DoesLocusIntersect.</returns>
        public Loci GetLocusIntersection(Loci pobjTarget)
        {
            switch (this.Type)
            {
            case LociType.Line:
                switch (pobjTarget.Type)
                {
                case LociType.Line:
                    PointF objReturn = PointF.Empty;
                    IntersectionHelpers.DoLinesIntersect(this.Line, pobjTarget.Line, ref objReturn);
                    return(new Loci(objReturn));

                case LociType.Point:
                    // Need to change this to return New Loci() if not intersecting.
                    return(new Loci(pobjTarget.Point));

                case LociType.Rectangle:
                    Line objReturn2 = null;
                    if (IntersectionHelpers.DoesLineIntersectRectangle(pobjTarget.Rectangle, this.Line, ref objReturn2))
                    {
                        return(new Loci(objReturn2));
                    }
                    else
                    {
                        return(new Loci());
                    }
                }
                break;

            case LociType.Point:
                switch (pobjTarget.Type)
                {
                case LociType.Line:
                    return(new Loci(this.Point));

                case LociType.Point:
                    return(new Loci(this.Point));

                case LociType.Rectangle:
                    return(new Loci(this.Point));
                }
                break;

            case LociType.Rectangle:
                switch (pobjTarget.Type)
                {
                case LociType.Line:
                    Line objReturn = null;
                    if (IntersectionHelpers.DoesLineIntersectRectangle(this.Rectangle, pobjTarget.Line, ref objReturn))
                    {
                        return(new Loci(objReturn));
                    }
                    else
                    {
                        return(new Loci());
                    }

                case LociType.Point:
                    return(new Loci(pobjTarget.Point));

                case LociType.Rectangle:
                    RectangleF objRectangle = new RectangleF(pobjTarget.Rectangle.Location, pobjTarget.Rectangle.Size);
                    objRectangle.Intersect(this.Rectangle);
                    return(new Loci(objRectangle));
                }
                break;
            }

            throw new NotSupportedException();
        }
Exemplo n.º 3
0
        /// <returns>Returns the loci which describes the intersection. WARNING: Where points are concerned it is assumed the point does intersect so the point simply gets returned. This is to prevent multiple calls to DoesLocusIntersect.</returns>
        public Loci GetLocusIntersection(Loci pobjTarget)
        {
            switch (this.Type)
            {
                case LociType.Line:
                    switch (pobjTarget.Type)
                    {
                        case LociType.Line:
                            PointF objReturn = PointF.Empty;
                            IntersectionHelpers.DoLinesIntersect(this.Line, pobjTarget.Line, ref objReturn);
                            return new Loci(objReturn);
                        case LociType.Point:
                            // Need to change this to return New Loci() if not intersecting.
                            return new Loci(pobjTarget.Point);
                        case LociType.Rectangle:
                            Line objReturn2 = null;
                            if (IntersectionHelpers.DoesLineIntersectRectangle(pobjTarget.Rectangle, this.Line, ref objReturn2))
                            {
                                return new Loci(objReturn2);
                            }
                            else
                            {
                                return new Loci();
                            }
                    }
                    break;
                case LociType.Point:
                    switch (pobjTarget.Type)
                    {
                        case LociType.Line:
                            return new Loci(this.Point);
                        case LociType.Point:
                            return new Loci(this.Point);
                        case LociType.Rectangle:
                            return new Loci(this.Point);
                    }
                    break;
                case LociType.Rectangle:
                    switch (pobjTarget.Type)
                    {
                        case LociType.Line:
                            Line objReturn = null;
                            if (IntersectionHelpers.DoesLineIntersectRectangle(this.Rectangle, pobjTarget.Line, ref objReturn))
                            {
                                return new Loci(objReturn);
                            }
                            else
                            {
                                return new Loci();
                            }
                        case LociType.Point:
                            return new Loci(pobjTarget.Point);
                        case LociType.Rectangle:
                            RectangleF objRectangle = new RectangleF(pobjTarget.Rectangle.Location, pobjTarget.Rectangle.Size);
                            objRectangle.Intersect(this.Rectangle);
                            return new Loci(objRectangle);
                    }
                    break;
            }

            throw new NotSupportedException();
        }
Exemplo n.º 4
0
        public bool DoesLocusIntersect(Loci pobjTarget)
        {
            PointF point = new PointF(0, 0);
            switch (this.Type)
            {
                case LociType.Line:
                    switch (pobjTarget.Type)
                    {
                        case LociType.Line:
                            return IntersectionHelpers.DoLinesIntersect(this.Line, pobjTarget.Line, ref point);
                        case LociType.Point:
                            return IntersectionHelpers.DoLinesIntersect(this.Line, pobjTarget.CreateLineFromPoint(), ref point);
                        case LociType.Rectangle:
                            return IntersectionHelpers.DoesLineIntersectRectangle(pobjTarget.Rectangle, this.Line);
                    }
                    break;
                case LociType.Point:
                    switch (pobjTarget.Type)
                    {
                        case LociType.Line:
                            return IntersectionHelpers.DoLinesIntersect(pobjTarget.Line, this.CreateLineFromPoint(), ref point);
                        case LociType.Point:
                            return this.Point.Equals(pobjTarget.Point);
                        case LociType.Rectangle:
                            return pobjTarget.Rectangle.Contains(this.Point);
                    }
                    break;
                case LociType.Rectangle:
                    switch (pobjTarget.Type)
                    {
                        case LociType.Line:
                            return IntersectionHelpers.DoesLineIntersectRectangle(this.Rectangle, pobjTarget.Line);
                        case LociType.Point:
                            return this.Rectangle.Contains(pobjTarget.Point);
                        case LociType.Rectangle:
                            return pobjTarget.Rectangle.IntersectsWith(this.Rectangle);
                    }
                    break;
            }

            throw new NotSupportedException();
        }