示例#1
0
        private void Calc_Area(ref Edge_qt edge)
        {
            double x = Math.Abs(edge.MaxX - edge.minX);
            double y = edge.MaxY;

            edge.Area_Enve = x * y;
        }
示例#2
0
        /// <summary>
        /// 获得向量spnt_epnt在线段上的投影
        /// </summary>
        /// <param name="edge"></param>
        /// <param name="spnt"></param>
        /// <param name="epnt"></param>
        /// <returns></returns>
        private double GetVecProj(Edge_qt edge, Point_qt spnt, Point_qt epnt)
        {
            Point_qt p1 = edge.FromNode;
            Point_qt p2 = edge.ToNode;

            double e1_x = p2.X - p1.X;
            double e1_y = p2.Y - p1.Y;
            double e2_x = spnt.X - epnt.X;
            double e2_y = spnt.Y - epnt.Y;

            return((e1_x * e2_x + e1_y * e2_y) / Math.Sqrt(e1_x * e1_x + e1_y * e1_y));
        }
示例#3
0
        /// <summary>
        /// 获得边Edge
        /// </summary>
        /// <param name="stack"></param>
        /// <returns></returns>
        private List <Edge_qt> GetListEdge(Stack <Point_qt> stack)
        {
            Edge_qt        edge;
            List <Edge_qt> list = new List <Edge_qt>();

            for (int i = 1; i < stack.Count; i++)
            {
                edge          = new Edge_qt();
                edge.FromNode = stack.ElementAt(i);
                edge.ToNode   = stack.ElementAt(i - 1);
                list.Add(edge);
            }

            return(list);
        }
示例#4
0
        /// <summary>
        /// 得到点线距
        /// </summary>
        /// <param name="edge"></param>
        /// <param name="pnt"></param>
        /// <returns></returns>
        private double GetD_PL(Edge_qt edge, Point_qt pnt)
        {
            double x = pnt.X;
            double y = pnt.Y;

            Point_qt p1 = edge.FromNode;
            Point_qt p2 = edge.ToNode;

            double m = p2.X - p1.X;
            double n = p2.Y - p1.Y;

            double fenzi = Math.Abs(n * x - n * p1.X - m * y + m * p1.Y);
            double fenmu = Math.Sqrt(n * n + m * m);

            return(fenzi / fenmu);
        }
示例#5
0
        /**
         * 以下是根据凸包得到一个最小外接矩形
         * 基本思想是:根据凸包的每条边算得一个外接矩形面积,最后选取SMBR
         */

        public List <Point_qt> GetSMBR()
        {
            Point_qt        p1   = new Point_qt();
            Point_qt        p2   = new Point_qt();
            Point_qt        p3   = new Point_qt();
            Point_qt        p4   = new Point_qt();
            List <Point_qt> list = new List <Point_qt>();

            Edge_qt edge = GetBestEdge();

            p1 = CalcPnt_Coor(edge.minX, edge.FromNode, edge.ToNode);
            p2 = CalcPnt_Coor(edge.MaxX, edge.FromNode, edge.ToNode);
            p3 = ReferencePoint_Clock(edge.MaxY, p2, p1);
            p4 = ReferencePoint_unClock(edge.MaxY, p1, p2);

            list.Add(p1);
            list.Add(p2);
            list.Add(p3);
            list.Add(p4);
            return(list);
        }
示例#6
0
 private void Calc_Args(ref Edge_qt edge, Stack <Point_qt> stack)
 {
     for (int i = 0; i < stack.Count; i++)
     {
         double dis = GetD_PL(edge, stack.ElementAt(i));
         if (dis > edge.MaxY)
         {
             edge.MaxY = dis;
         }
         double mx = GetVecProj(edge, stack.ElementAt(i));
         if (mx < 0 && mx < edge.minX)
         {
             edge.minX     = mx;
             edge.minXNode = stack.ElementAt(i);
         }
         else if (mx > 0 && mx > edge.MaxX)
         {
             edge.MaxX     = mx;
             edge.MaxXNode = stack.ElementAt(i);
         }
     }
 }