private double GetDistance(GraphicPathFacade first, GraphicPathFacade last)
        {
            if (first == last)
                return 0;

            var from = first.EndPoint;
            var to = last.StartPoint;

            return Math.Sqrt(Math.Pow(from.X - to.X, 2) + Math.Pow(from.Y - to.Y, 2));
        }
Esempio n. 2
0
        private double GetDistance(GraphicPathFacade first, GraphicPathFacade last)
        {
            if (first == last)
            {
                return(0);
            }

            var from = first.EndPoint;
            var to   = last.StartPoint;

            return(Math.Sqrt(Math.Pow(from.X - to.X, 2) + Math.Pow(from.Y - to.Y, 2)));
        }
Esempio n. 3
0
        /*private PointF GetFirstPoint(GraphicsPath path)
         * {
         *  return path.PathPoints[0];
         * }
         *
         * private PointF GetLastPoint(GraphicsPath path)
         * {
         *  if (Geometry.PathTypeHelper.IsSet(path.PathTypes.Last(), System.Drawing.Drawing2D.PathPointType.CloseSubpath))
         *      return path.PathPoints[0];
         *
         *  return path.PathPoints.Last();
         * }*/

        public GraphicPathFacade GetClosestToZeroPath(out int index)
        {
            double            MinDistanceToZero = double.PositiveInfinity;
            GraphicPathFacade ClosestToZero     = null;

            foreach (var item in _paths)
            {
                var dist = Math.Pow(item.StartPoint.X, 2) + Math.Pow(item.StartPoint.Y, 2);

                if (dist < MinDistanceToZero)
                {
                    ClosestToZero     = item;
                    MinDistanceToZero = dist;
                }
            }
            index = _paths.IndexOf(ClosestToZero);

            return(ClosestToZero);
        }