(
self,
center: Optional[Point] = None,
radius: Optional[float] = None,
p1: Optional[Point] = None,
p2: Optional[Point] = None,
p3: Optional[Point] = None,
)
| 389 | """Numerical circle.""" |
| 390 | |
| 391 | def __init__( |
| 392 | self, |
| 393 | center: Optional[Point] = None, |
| 394 | radius: Optional[float] = None, |
| 395 | p1: Optional[Point] = None, |
| 396 | p2: Optional[Point] = None, |
| 397 | p3: Optional[Point] = None, |
| 398 | ): |
| 399 | if not center: |
| 400 | if not (p1 and p2 and p3): |
| 401 | self.center = self.radius = self.r2 = None |
| 402 | return |
| 403 | # raise ValueError('Circle without center need p1 p2 p3') |
| 404 | |
| 405 | l12 = _perpendicular_bisector(p1, p2) |
| 406 | l23 = _perpendicular_bisector(p2, p3) |
| 407 | center = line_line_intersection(l12, l23) |
| 408 | |
| 409 | self.center = center |
| 410 | self.a, self.b = center.x, center.y |
| 411 | |
| 412 | if not radius: |
| 413 | if not (p1 or p2 or p3): |
| 414 | raise ValueError('Circle needs radius or p1 or p2 or p3') |
| 415 | p = p1 or p2 or p3 |
| 416 | self.r2 = (self.a - p.x) ** 2 + (self.b - p.y) ** 2 |
| 417 | self.radius = math.sqrt(self.r2) |
| 418 | else: |
| 419 | self.radius = radius |
| 420 | self.r2 = radius * radius |
| 421 | |
| 422 | def intersect(self, obj: Union[Line, Circle]) -> tuple[Point, ...]: |
| 423 | if isinstance(obj, Line): |
nothing calls this directly
no test coverage detected