Exemplo n.º 1
0
        public static double Length(ILucidLine line)
        {
            double length = 0;

            foreach (var subline in line.Vertices.SlidingWindow(2))
            {
                length += Math.Abs(GeometryHelper.DistanceBetween(subline.First(), subline.Last()));
            }

            return(length);
        }
Exemplo n.º 2
0
        public static IEnumerable <ILucidGeometry> FindNearby(IEnumerable <IPoint> referencePoints, double distance, IEnumerable <ILucidGeometry> geometries, bool recursive = false)
        {
            var nearbyGeometries = (from g in geometries
                                    let nearbyVertices = from v in g.Vertices
                                                         where referencePoints.Where(p => GeometryHelper.DistanceBetween(p, v) < distance).Any()
                                                         select v
                                                         where nearbyVertices.Any()
                                                         select g);

            foreach (var geometry in nearbyGeometries)
            {
                yield return(geometry);
            }

            if (recursive && nearbyGeometries.Any())
            {
                foreach (var nearby in FindNearby(nearbyGeometries.SelectMany(g => g.Vertices), distance, geometries.Except(nearbyGeometries), recursive))
                {
                    yield return(nearby);
                }
            }
        }