def _fill_circle(self, radius): dist = 300 / self.points center = point(0, 0) point_list = [] i = 0 while i < self.size * (radius / 90): temp_point = point(random.randint(-1000, 1000), random.randint(-1000, 1000)) if temp_point.distance( center) <= radius + dist and temp_point.distance( center) >= radius - dist: point_list.append(temp_point) i += 1 return point_list
def get_mean(point_list): total_x = 0 total_y = 0 for pnt in point_list: total_x += pnt.x() total_y += pnt.y() return point(total_x / len(point_list), total_y / len(point_list))
def _fill_list(self): self.list.append( point(random.randint(-1000, 1000), random.randint(-1000, 1000))) set_points = 1 while set_points != self.points: temp_point = point(random.randint(-1000, 1000), random.randint(-1000, 1000)) if self._is_set_valid(temp_point): set_points += 1 self.list.append(temp_point) total = self.points + 1 while total != self.size: temp_point = point(random.randint(-1000, 1000), random.randint(-1000, 1000)) if self._is_valid(temp_point): self.list.append(temp_point) total += 1
def _fill_list(self): for _ in range(self.lines): m = random.randint(-10, 10) c = random.randint(-1000, 1000) for _ in range(self.size): x = random.randint(-1000, 1000) y = (m * x + c) % 2000 - 1000 + (random.randint(-5, 5)) self.list.append(point(x, y))
def _fill_list(self): for _ in range(self.count): m = random.randint(-10, 10) c = random.randint(-1000, 1000) for _ in range(self.size): x = random.randint(-1000, 1000) y = (m * pow(x, self.power) + c) % 2000 - 1000 + ( random.randint(-5, 5)) self.list.append(point(x, y))
def get_points_from_file(file): file.readline() file.readline() points = [] for line in file: if line == '\n': break points.append(point(int(line.split()[0]), int(line.split()[-1]))) return points
def _fill_list(self): for _ in range(self.size): self.list.append( point(random.randint(-1000, 1000), random.randint(-1000, 1000)))