Exemplo n.º 1
0
        private double GetRadius(IEnumerable <Point> points)
        {
            if (points.Count() > 1)
            {
                double maxX = double.MinValue;
                double maxY = double.MinValue;
                double minX = double.MaxValue;
                double minY = double.MaxValue;
                foreach (var point in points)
                {
                    if (maxX < point.X)
                    {
                        maxX = point.X;
                    }
                    if (maxY < point.Y)
                    {
                        maxY = point.Y;
                    }
                    if (minX > point.X)
                    {
                        minX = point.X;
                    }
                    if (minY > point.Y)
                    {
                        minY = point.Y;
                    }
                }

                return(MathMethods.GetDistanceBetTowPoints(maxX, maxY, minX, minY) / 2);
            }
            return(0);
        }
Exemplo n.º 2
0
        public static double GetExceptionPoint(this IEnumerable <Point> input, out Point exceptionPoint)
        {
            int count = input.Count();
            Dictionary <int, double> keys = new Dictionary <int, double>();

            for (int i = 0; i < count; i++)
            {
                double avg = 0;
                for (int j = 0; j < count; j++)
                {
                    double distance = MathMethods.GetDistanceBetTowPoints(input.ElementAt(i).X, input.ElementAt(i).Y, input.ElementAt(j).X, input.ElementAt(j).X);
                    avg += distance;
                }
                avg = avg / count;
                keys.Add(i, avg);
            }
            double max    = 0;
            int    target = -1;

            foreach (var item in keys)
            {
                if (item.Value > max)
                {
                    max    = item.Value;
                    target = item.Key;
                }
            }
            exceptionPoint = input.ElementAt(target);
            return(keys[target]);
        }