Пример #1
0
        public override GlPointR2[] getIntersection(GlPolygon POLY)
        {
            List <GlPointR2> Intersections = new List <GlPointR2>();

            GlLineR2 fCurLine = new GlLineR2(this[this.CountOfPoints - 1], new GlVectorR2(this[0].X - this[this.CountOfPoints - 1].X, this[0].Y - this[this.CountOfPoints - 1].Y));

            GlPointR2[] faultInter = fCurLine.getIntersection(POLY);
            foreach (GlPointR2 j in faultInter)
            {
                if (new GlLineSegment(this[this.CountOfPoints - 1], this[0]).isPointBelongs(j))
                {
                    Intersections.Add(j);
                }
            }

            for (int i = 0; i < this.CountOfPoints - 1; i++)
            {
                fCurLine   = new GlLineR2(this[i], new GlVectorR2(this[i + 1].X - this[i].X, this[i + 1].Y - this[i].Y));
                faultInter = fCurLine.getIntersection(POLY);
                foreach (GlPointR2 j in faultInter)
                {
                    if (new GlLineSegment(this[i], this[i + 1]).isPointBelongs(j))
                    {
                        Intersections.Add(j);
                    }
                }
            }

            return(Intersections.ToArray());
        }
Пример #2
0
        //////////////TRANSFORM_METHODS////////////////
        ///////////////////////////////////////////////
        /////////////INTERSECTION_METHODS//////////////

        /// <summary>
        /// Determines the intersection of a point and a line
        /// </summary>
        /// <returns>An array containing a copy of given point if it belongs to the line</returns>
        public override GlPointR2[] getIntersection(GlLineR2 L)
        {
            return(L == null ? new GlPointR2[] { } : L.getIntersection(this));
        }