def draw_clusters(self, N, cluster_size, hard_radius=None, separation=0, margin=None): """Draws N clusters at random locations, using minimum separation and a margin. If separation > 0, less than N features may be drawn.""" if hard_radius is None: hard_radius = self.hard_radius if margin is None: margin = self.hard_radius if margin is None: margin = 0 pos = gen_random_locations(self.shape, N, margin) if separation > 0: pos = drop_close(pos, separation) if self.ndim == 2: angles = np.random.uniform(0, 2 * np.pi, N) elif self.ndim == 3: angles = np.random.uniform(0, 2 * np.pi, (N, 3)) for p, a in zip(pos, angles): self.draw_cluster(cluster_size, p, a, hard_radius) return pos
def gen_nonoverlapping_locations(shape, count, separation, margin=0): """ Generates `count` number of positions within `shape`, that have minimum distance `separation` from each other. The number of positions returned may be lower than `count`, because positions too close to each other will be deleted. If a `margin` is given, positions will be inside this margin. Margin may be tuple-valued. """ positions = gen_random_locations(shape, count, margin) return drop_close(positions, separation)
def gen_nonoverlapping_locations(shape, count, separation, margin=0): """ Generates `count` number of positions within `shape`, that have minimum distance `separation` from each other. The number of positions returned may be lower than `count`, because positions too close to each other will be deleted. If a `margin` is given, positions will be inside this margin. Margin may be tuple-valued. """ positions = gen_random_locations(shape, count, margin) return drop_close(positions, separation)
def draw_features(self, N, separation=0, margin=None): """Draws N features at random locations, using minimum separation and a margin. If separation > 0, less than N features may be drawn.""" if margin is None: margin = self.hard_radius if margin is None: margin = 0 pos = gen_random_locations(self.shape, N, margin) if separation > 0: pos = drop_close(pos, separation) for p in pos: self.draw_feature(p) return pos
def draw_features(self, N, separation=0, margin=None): """Draws N features at random locations, using minimum separation and a margin. If separation > 0, less than N features may be drawn.""" if margin is None: margin = self.hard_radius if margin is None: margin = 0 pos = gen_random_locations(self.shape, N, margin) if separation > 0: pos = drop_close(pos, separation) for p in pos: self.draw_feature(p) return pos
def draw_clusters(self, N, cluster_size, hard_radius=None, separation=0, margin=None): """Draws N clusters at random locations, using minimum separation and a margin. If separation > 0, less than N features may be drawn.""" if hard_radius is None: hard_radius = self.hard_radius if margin is None: margin = self.hard_radius if margin is None: margin = 0 pos = gen_random_locations(self.shape, N, margin) if separation > 0: pos = drop_close(pos, separation) if self.ndim == 2: angles = np.random.uniform(0, 2*np.pi, N) elif self.ndim == 3: angles = np.random.uniform(0, 2*np.pi, (N, 3)) for p, a in zip(pos, angles): self.draw_cluster(cluster_size, p, a, hard_radius) return pos