Exemple #1
0
        private PointF[] GetPointArray(CircularLinkedList <Vector2> list)
        {
            var currentNode = list.First;
            var result      = new PointF[list.Count];

            for (var i = 0; i < list.Count; i++)
            {
                result[i]   = ConvertToScreenCoord(currentNode.Value.X, currentNode.Value.Y);
                currentNode = list.NextOrFirst(currentNode);
            }

            return(result);
        }
Exemple #2
0
        private bool IsOnWindow(CircularLinkedList <Vector2> list, Vector2 point)
        {
            var cur = list.First;

            for (var i = 0; i < list.Count; i++)
            {
                var prev = cur;
                cur = list.NextOrFirst(cur);
                if (IsBelongsLine(prev.Value, cur.Value, point) && IsPointInside(prev.Value, cur.Value, point))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #3
0
        private bool IsInside(Vector2 point, CircularLinkedList <Vector2> list)
        {
            var flag = false;
            var prev = list.Last;
            var cur  = list.First;

            for (var i = 0; i < list.Count; i++)
            {
                if ((cur.Value.Y <= point.Y && point.Y < prev.Value.Y ||
                     prev.Value.Y <= point.Y && point.Y < cur.Value.Y) &&
                    point.X > (prev.Value.X - cur.Value.X) * (point.Y - cur.Value.Y) / (prev.Value.Y - cur.Value.Y) +
                    cur.Value.X)
                {
                    flag = !flag;
                }
                prev = cur;
                cur  = list.NextOrFirst(cur);
            }

            return(flag);
        }