Ejemplo n.º 1
0
        public static bool isInside(AreaVertex v1, List <AreaVertex> outline)
        {
            var v2 = new AreaVertex();

            var crossings = 0;

            for (int i = 0; i < outline.Count; i++)
            {
                var b1 = outline.ElementAt(i);
                var k  = i + 1;
                if (i == outline.Count - 1)
                {
                    k = 0;
                }
                var b2 = outline.ElementAt(k);
                if (v1.Equals(b1) || v1.Equals(b2) || v2.Equals(b1) || v2.Equals(b2))
                {
                    continue;
                }
                if (isRightHanded(new List <AreaVertex>()
                {
                    v1, b1, b2
                }) == isRightHanded(new List <AreaVertex>()
                {
                    v2, b1, b2
                }))
                {
                    continue;
                }
                else if (isRightHanded(new List <AreaVertex>()
                {
                    v1, v2, b1
                }) == isRightHanded(new List <AreaVertex>()
                {
                    v1, v2, b2
                }))
                {
                    continue;
                }
                else
                {
                    crossings++;
                }
            }
            return(crossings % 2 == 1);
        }
Ejemplo n.º 2
0
        private static bool lineIntersect(AreaVertex v1, AreaVertex v2, List <AreaVertex> outline)
        {
            bool intersects = false;

            for (int i = 0; i < outline.Count; i++)
            {
                var b1 = outline.ElementAt(i);
                var k  = i + 1;
                if (i == outline.Count - 1)
                {
                    k = 0;
                }
                var b2 = outline.ElementAt(k);
                if (v1.Equals(b1) || v1.Equals(b2) || v2.Equals(b1) || v2.Equals(b2))
                {
                    continue;
                }
                if (isRightHanded(new List <AreaVertex>()
                {
                    v1, b1, b2
                }) == isRightHanded(new List <AreaVertex>()
                {
                    v2, b1, b2
                }))
                {
                    continue;
                }
                else if (isRightHanded(new List <AreaVertex>()
                {
                    v1, v2, b1
                }) == isRightHanded(new List <AreaVertex>()
                {
                    v1, v2, b2
                }))
                {
                    continue;
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }