Пример #1
0
        /// <summary>
        /// Get all notches in a list of ordered points that represent the vertices of
        /// a polygon. A notch is a point that the reflex angle in internal.
        /// </summary>
        /// <param name="points">
        /// The poitns in the LinkedList must be ordered in clockwise order.
        /// </param>
        /// <returns>
        /// Returns a List with the notches.
        /// </returns>
        private List <UV> GetNotches(CircularLinkedList <UV> points)
        {
            List <UV> notches = new List <UV>();

            if (points.Count < 5)
            {
                return(notches);
            }

            CircularLinkedListNode <UV> node = points.Head;

            do
            {
                UV     p0    = node.Value;
                UV     p1    = node.Next.Value;
                UV     p2    = node.Next.Next.Value;
                double angle = VectorManipulator.CalculatesAngle(p0, p1, p2);
                if (angle > Math.PI)
                {
                    notches.Add(p1);
                }

                node = node.Next;
            } while (node != points.Head);

            return(notches);
        }
Пример #2
0
        public bool Normalize()
        {
            bool normalized = true;
            CircularLinkedList <UV>     points = GetPoints();
            CircularLinkedListNode <UV> node   = points.Head;

            do
            {
                UV p0 = node.Previous.Value;
                UV p1 = node.Value;
                UV p2 = node.Next.Value;

                double angle = VectorManipulator.CalculatesAngle(p0, p1, p2);
                if (AlmostEqual(angle, Math.PI, 0.01) || AlmostEqual(angle, 0, 0.01))
                {
                    points.Remove(p1);
                    normalized = false;
                }
                node = node.Next;
            } while (node != points.Head);

            curveArray = CreateCurveArrayFromPoints(points);

            if (!normalized)
            {
                Normalize();
            }

            return(normalized);
        }