public static Section GetFrom(List<Section> sections, Vector vec)
 {
     foreach (Section section in sections)
     {
         if (section.Equals(vec))
             return section;
     }
     return null;
 }
 public Section(Vector vector, Triangle left = null, Triangle right = null)
 {
     this.Vector = vector;
     this.Left = left;
     this.Right = right;
 }
        private void UpdateShell()
        {
            /*
             * Идея следующая: берем два соседних ребра в оболочке, (по способу построения они идут против часовой стрелки)
             * вычисляем их векторное произведение. Если оно положительно - оболочка не выпукла, нужно добавить в неё ребро,
             * а эти два удалить. Так же, нужно добавить треугольник. И так до тех пор, пока не сделаем полный проход, при этом
             * не изменив ни одного ребра.
             */
            bool shellChanged = true;
            while (shellChanged)
            {
                shellChanged = false;
                for (int i = 0; i < shell.Count - 1; i++)
                {
                    if (shell[i].GetVectorMultiplication(shell[i + 1]) < 0)
                    {
                        triangles.Add(new Triangle(shell[i].Start, shell[i].End, shell[i + 1].End));

                        shell[i] = new Vector(shell[i].Start, shell[i + 1].End);
                        shell.RemoveAt(i + 1);

                        shellChanged = true;
                    }
                }

                if (shell[shell.Count - 1].GetVectorMultiplication(shell[0]) < 0)
                {
                    Triangle t = new Triangle(shell[shell.Count - 1].Start,  shell[0].End, shell[shell.Count - 1].End);
                    triangles.Add(t);

                    shell[shell.Count - 1] = new Vector(shell[shell.Count - 1].Start, shell[0].End);
                    shell.RemoveAt(0);

                    shellChanged = true;
                }
            }
        }
 public double GetVectorMultiplication(Vector vector)
 {
     return Dx * vector.Dy - Dy * vector.Dx;
 }
        public double GetSumOfAngles(Point point)
        {
            Vector vecRight = new Vector(Start, point);
            Vector vecLeft = new Vector(End, point);

            double angleRight = 180 * (Math.Acos(GetDotMultiplication(vecRight) / (Length * vecRight.Length))) / Math.PI;
            double angleLeft = 180 * (Math.Acos((new Vector(End, Start).GetDotMultiplication(vecLeft)) / (Length * vecLeft.Length))) / Math.PI;
            return angleLeft + angleRight;
        }
 public Vector GetSum(Vector vector)
 {
     return new Vector(Start, new Point(Start.X + Dx + vector.Dx, Start.Y + Dy + vector.Dy));
 }
 public double GetDotMultiplication(Vector vector)
 {
     return Dx * vector.Dx + Dy * vector.Dy;
 }