private static IEnumerable <Point2d> RadialDistanceSafe(this IEnumerable <Point2d> points, double tol2)
        {
            IEnumerator <Point2d> enumer = points.GetEnumerator();

            if (!enumer.MoveNext())
            {
                yield break;
            }

            Point2d current = enumer.Current;

            // El primer punto siempre se añade.
            yield return(current);

            if (enumer.MoveNext())
            {
                Point2d next = enumer.Current;
                bool    lastInResult;
                do
                {
                    lastInResult = (current.Distance2To(next) >= tol2);
                    if (lastInResult)
                    {
                        current = next;
                        yield return(current);
                    }
                }while (enumer.MoveNext());

                // El ultimo punto siempre se añade.
                if (!lastInResult)
                {
                    yield return(next);
                }
            }
        }
        public static void RadialDistance(this IEnumerable <Point2d> points, double tol, Action <Point2d> result)
        {
            double tol2 = tol * tol;

            if (tol2.EpsilonEquals(0))
            {
                foreach (Point2d p in points)
                {
                    result(p);
                }
                return;
            }

            IEnumerator <Point2d> enumer = points.GetEnumerator();

            if (!enumer.MoveNext())
            {
                return;
            }

            Point2d current = enumer.Current;

            // El primer punto siempre se añade.
            result(current);

            if (enumer.MoveNext())
            {
                Point2d next = enumer.Current;
                bool    lastInResult;
                do
                {
                    lastInResult = (current.Distance2To(next) >= tol2);
                    if (lastInResult)
                    {
                        current = next;
                        result(current);
                    }
                }while (enumer.MoveNext());

                // El ultimo punto siempre se añade.
                if (!lastInResult)
                {
                    result(next);
                }
            }
        }
 public static double point_distance2(Point2d p1, Point2d p2)
 {
     return(p1.Distance2To(p2));
 }