(self, points: list[Point], n: int = 5)
| 348 | raise InvalidLineIntersectError() |
| 349 | |
| 350 | def sample_within(self, points: list[Point], n: int = 5) -> list[Point]: |
| 351 | center = sum(points, Point(0.0, 0.0)) * (1.0 / len(points)) |
| 352 | radius = max([p.distance(center) for p in points]) |
| 353 | if close_enough(center.distance(self.line), radius): |
| 354 | center = center.foot(self) |
| 355 | a, b = line_circle_intersection(self, Circle(center.foot(self), radius)) |
| 356 | |
| 357 | if (a - self.tail).dot(self.head - self.tail) > 0: |
| 358 | a, b = self.tail, a |
| 359 | else: |
| 360 | a, b = self.tail, b # pylint: disable=self-assigning-variable |
| 361 | |
| 362 | result = None |
| 363 | best = -1.0 |
| 364 | for _ in range(n): |
| 365 | x = a + (b - a) * unif(0.0, 1.0) |
| 366 | mind = min([x.distance(p) for p in points]) |
| 367 | if mind > best: |
| 368 | best = mind |
| 369 | result = x |
| 370 | |
| 371 | return [result] |
| 372 | |
| 373 | |
| 374 | def _perpendicular_bisector(p1: Point, p2: Point) -> Line: |
nothing calls this directly
no test coverage detected