/// <summary>
        /// Returns true if vertex j can be seen from vertex i without any obstructions.
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="i"></param>
        /// <param name="j"></param>
        /// <returns></returns>
        private bool CanSee(Polygon polygon, int i, int j)
        {
            Microsoft.Xna.Framework.Vector2 prev = polygon.At(i - 1);
            Microsoft.Xna.Framework.Vector2 on   = polygon.At(i);
            Microsoft.Xna.Framework.Vector2 next = polygon.At(i + 1);

            if (IsReflex(prev, on, next))
            {
                if (LeftOrOn(polygon.At(i), polygon.At(i - 1), polygon.At(j)) &&
                    RightOrOn(polygon.At(i), polygon.At(i + 1), polygon.At(j)))
                {
                    return(false);
                }
            }
            else
            {
                if (RightOrOn(polygon.At(i), polygon.At(i + 1), polygon.At(j)) ||
                    LeftOrOn(polygon.At(i), polygon.At(i - 1), polygon.At(j)))
                {
                    return(false);
                }
            }

            Microsoft.Xna.Framework.Vector2 prevj = polygon.At(j - 1);
            Microsoft.Xna.Framework.Vector2 onj   = polygon.At(j);
            Microsoft.Xna.Framework.Vector2 nextj = polygon.At(j + 1);

            if (IsReflex(prevj, onj, nextj))
            {
                if (LeftOrOn(polygon.At(j), polygon.At(j - 1), polygon.At(i)) &&
                    RightOrOn(polygon.At(j), polygon.At(j + 1), polygon.At(i)))
                {
                    return(false);
                }
            }
            else
            {
                if (RightOrOn(polygon.At(j), polygon.At(j + 1), polygon.At(i)) ||
                    LeftOrOn(polygon.At(j), polygon.At(j - 1), polygon.At(i)))
                {
                    return(false);
                }
            }

            for (int k = 0; k < polygon.Count; ++k)
            {
                // YOGESH : changed from Line-Line intersection to Segment-Segment Intersection
                Microsoft.Xna.Framework.Vector2 p1 = polygon.At(i);
                Microsoft.Xna.Framework.Vector2 p2 = polygon.At(j);
                Microsoft.Xna.Framework.Vector2 q1 = polygon.At(k);
                Microsoft.Xna.Framework.Vector2 q2 = polygon.At(k + 1);

                // ignore incident edges
                if (p1.Equals(q1) || p1.Equals(q2) || p2.Equals(q1) || p2.Equals(q2))
                {
                    continue;
                }

                var intersection = LineAlgorithms.LineSegmentIntersection(p1, p2, q1, q2);

                if (intersection != null &&
                    intersection.WithinFirstSegment &&
                    intersection.WithinSecondSegment)
                {
                    Microsoft.Xna.Framework.Vector2 intPoint = intersection.IntersectionPoint;

                    // intPoint is not any of the j line then false, else continue. Intersection has to be interior to qualify s 'false' from here
                    if ((!intPoint.Equals(polygon.At(k))) || (!intPoint.Equals(polygon.At(k + 1))))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }